Creating node with prefix
How can i create a node like d2l_2p0:difficulty in xml file using asp.net开发者_如何转开发
Assuming you need to load an xml file that already exists from you file system, here is the easiest way to accomplish what your asking.
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"<The absolute path of your xml document>");
XmlNode node = xmlDoc.DocumentElement;
XmlElement element = xmlDoc.CreateElement("difficulty");
element.Prefix = "d2I_2p0";
node.AppendChild(element);
xmlDoc.Save(@"<path you would like to save the file to>");
精彩评论