Add elements to xml file in WP7?

后端 未结 2 1009
挽巷
挽巷 2021-01-25 03:15

How do you add an element to an xml file in wp7? I HAVE found alot of sources that show how to add elements in ASP.NET, Silverlight on the browser, etc.. but nothing on wp7. I k

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 03:36

    XDocument usage on WP7 is the same as it is for silverlight. Try something like this:

    string xmlStr = "Hello";
    XDocument document = XDocument.Parse(xmlStr);
    document.Root.Add(new XElement("ChildNode", "World!"));
    string newXmlStr = document.ToString(); 
    // The value of newXmlStr is now: "HelloWorld!"
    

提交回复
热议问题