标签:lin school ring loop move ESS reader code doc
XML处理
XDocument customer =
new XDocument(
new XDeclaration("1.0", "UTF-16", "yes"),
new XElement("customer",
new XAttribute("id", "C01"),
new XElement("firstName", "Paolo"),
new XElement("lastName", "Pialorsi"),
new XElement("addresses",
new XElement("address",
new XAttribute("type", "email"),
"paolo@devleap.it"),
new XElement("address",
new XAttribute("type", "url"),
"http://www.devleap.it/"),
new XElement("address",
new XAttribute("type", "home"),
"Brescia - Italy"))));
LINQ create xml document is very easy,and clearly.
//1.Declare Xdocument and have to set root node XDocument Content = new XDocument( new XElement("json") ); //2.Add element to document XAttribute ID = new XAttribute("id", 1); XElement XmlElement = new XElement("School", ID, "南十三大学"); Content.Root.Add(XmlElement);
3.How to remove all nodes attributes?
Content.Descendants().Attributes().Remove();
XmlReader reader = Content.Root.CreateReader(); reader.MoveToContent(); string result = reader.ReadInnerXml();
标签:lin school ring loop move ESS reader code doc
原文地址:https://www.cnblogs.com/tangpeng97/p/13029730.html