向 WP7 中的 xml 文件添加元素? [英] Add elements to xml file in WP7?
本文介绍了向 WP7 中的 xml 文件添加元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
wp7中如何向xml文件中添加元素?我找到了很多显示如何在 ASP.NET、浏览器上的 Silverlight 等中添加元素的来源,但在 wp7 上没有.我一直看到我们应该使用 XDocument(XML to Linq),只是不知道从哪里开始.谢谢.
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 keep seeing that we're supposed to use XDocument(XML to Linq), just not sure where to start. Thanks.
推荐答案
XDocument 在 WP7 上的使用与 Silverlight 上的相同.尝试这样的事情:
XDocument usage on WP7 is the same as it is for silverlight. Try something like this:
string xmlStr = "<RootNode><ChildNode>Hello</ChildNode></RootNode>";
XDocument document = XDocument.Parse(xmlStr);
document.Root.Add(new XElement("ChildNode", "World!"));
string newXmlStr = document.ToString();
// The value of newXmlStr is now: "<RootNode><ChildNode>Hello</ChildNode><ChildNode>World!</ChildNode></RootNode>"
这篇关于向 WP7 中的 xml 文件添加元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文