开发者

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>");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜