我有这个 XML:
<location>
<character name="name" mask="pap.png" X="397" Y="60">
<look reaction="False">
text1
<answer>text2</answer>
</look>
<talk xml=""/>
</character>
</location>
我可以访问节点。我在更改text1
和时遇到了一些问题text2
。这是我的代码:
node.ChildNodes[0].InnerText = "new_text1";
node.ChildNodes[0].ChildNodes[0].InnerText = "new_text2"; //this doesn't work
之后我的 XML 看起来像:
<location>
<character name="name" mask="pap.png" X="397" Y="60">
<look reaction="False">text1</look>
<talk xml=""/>
</character>
</location>
所以它切断了<answer/>
孩子。有任何想法吗?