1
我試着讀取一個XML文件,但沒有收到只有空格或製表符或新行的節點的內容。請告訴我我錯在哪裏。用cml中的XmlDocument讀取XML文件
XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<paragraph>
<sentence>
<sequence>
<word>aaa</word>
<space> </space>
</sequence>
<sequence>
<word>bbb</word>
<space> </space>
</sequence>
<sequence>
<word>ccc</word>
<space>?!</space>
</sequence>
</sentence>
</paragraph>
</root>
的代碼:
XmlDocument doc = new XmlDocument();
doc.Load("D:/Licenta/files/struct.xml");
XmlNodeList sentences = doc.DocumentElement.SelectNodes("/root/paragraph");
foreach (XmlNode sentence in sentences) {
Console.WriteLine(sentence.InnerText);
}
Console.ReadLine();
輸出: aaabbbccc?
你是否在這篇文章中表現了空間性格?http://stackoverflow.com/questions/514635/represent-space-and-tab-in-xml-tag? – erik
現在我嘗試了這個解決方案,它完美的工作。謝謝。 – alexeevyci