[問題] Xml節點問題
我的問題是這樣的
我想產生一個Xml檔案,而檔案的內容如下
<Battle>
<modle_stuff_growth_rule_list>
<stuff_growth_rule>
</stuff_growth_rule>
</modle_stuff_growth_rule_list>
</Battle>
我想產生一個如上所描述的xml格式
程式碼如下:
private void SaveQualityxml(string filename)
{
XmlDocument xmlDoc;
XmlElement rootNode;
xmlDoc = new XmlDocument();
XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0",
"utf-8", null);
xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement);
rootNode = xmlDoc.CreateElement("Battle");
xmlDoc.AppendChild(rootNode);
XmlElement QualityNode = xmlDoc.CreateElement("Stuff_Name");
rootNode.AppendChild(QualityNode);
XmlText QualityValue = xmlDoc.CreateTextNode(QualityName.Text);
QualityNode.AppendChild(QualityValue);
xmlDoc.Save(filename);
}
這段程式碼所產生出來的Xml結變成
<Battle>
<modle_stuff_growth_rule_list>
<Stuff_Name>
</Stuff_Name>
</modle_stuff_growth_rule_list>
</Battle>
我想問一下,要如何改成一開始所描述的Xml格式?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.204.17.136
※ 編輯: party100046 來自: 123.204.17.136 (07/27 19:57)
→
07/27 20:30, , 1F
07/27 20:30, 1F
→
07/27 21:48, , 2F
07/27 21:48, 2F