向"孟子E章"和其他网友请教关于XML的问题
原文件:
<Info></Info>
添加数据:
<Info>
<Informations>
<Ticket Tsn="196def5bcd27c1bc" VoteID="39">
<甲 A="true" B="false" />
</Ticket>
<Informations>
</Info>
再添加--->> N
<Info>
<Informations>
<Ticket Tsn="196def5bcd27c1bc" VoteID="39">
<甲 A="true" B="false" />
</Ticket>
<Informations>
<Informations>
<Ticket Tsn="199def5bcd27c1bc" VoteID="39">
<乜 A="true" B="false" />
</Ticket>
<Informations>
。。。。。。。。。。。。。
</Info>
问题,
我现在添加的不是节点,而是节点下面的一整块,如:
<Informations>
<Ticket Tsn="199def5bcd27c1bc" VoteID="39">
<乜 A="true" B="false" />
</Ticket>
<Informations>
一段一段的添加, 请问有没有好的方法,
如:
String text = "<Informations>"
+ "<Ticket Tsn=\"199def5bcd27c1bc\" VoteID=\"39\">"
+ "<乜 A=\"true\" B=\"false\" />"
+ "</Ticket>"
+ "<Informations>"
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("../xml1.xml");
XmlNode root = xmldoc.DocumentElement;
XmlText elem = xmldoc.CreateTextNode(text);
root.InsertAfter(elem,root.FirstChild);
xmldoc.Save(("../xml1.xml");
以上只是添加一个XmlText文本,我想添加节点, 请高手解解``` ,