1
當遇到</Text>
時,當我調用方法setStringValue: mCurrentString
時,已經附加到該元素的子元素將被分離。任何人都可以提出爲什麼會這樣發生。在NSXMLNode中附加字符串
的示例XML文件是這樣的:
<?xml version="1.0" encoding="UTF-8"?>
<Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0">
<Page Id="123-234-345-456-567">
<Word/>
<Text Id="234-345-456-567-678" Left="120.789" Top="120.234657" Width="300.2390" Height="50.00">
<Content>
<![CDATA[<FlowDocument FontFamily="Helvetica" FontSize="24" Foreground="#FFFFFF00" TextAlignment="Left" PagePadding="5,0,5,0" AllowDrop="True" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph><Run FontFamily="Helvetica" FontSize="24" Foreground="FF00B38D" xml:lang="en-gb">This is for Testing purpose</Run></Paragraph>]]></Content>
<Stroke Color="#FF00B300" Width="10"/>
</Text>
<Image Id="345-456-567-678-789" Left="200.345" Top="350.678" Width="200.00" Height="200.00">
<Source>Bear.png</Source>
</Image>
</Page>
<Page Id="345-897-123-756-098" Left="100.90" Top="200.098" Width="200.098" Height="50.09">
<Image Id="756-098-978-685-298" Left="12098" Top="340.87" Right="109.78" Height="100.987">
<Source>Flower.png</Source>
</Image>
</Page>
</Test>
這是我使用用於NSXMLElement對象的方法:
// mCurrentString is the string that obtained through delegate method.
[mCurrentElement setStringValue: mCurrentString];
嗨,你能編輯你的問題更清楚一點嗎? – 2010-03-07 00:09:19
嗨,setStringValue:是NSXMlNode可以調用來設置其字符串值的方法。無論如何,我得到了答案。 – boom 2010-03-08 05:25:56