In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to operate xml. Net has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The code is as follows:
Using System.Xml;// initializes a xml instance XmlDocument xml=new XmlDocument (); / / imports the specified xml file xml.Load (path); xml.Load (HttpContext.Current.Server.MapPath ("~ / file/bookstore.xml")); / / specifies a node XmlNode root=xml.SelectSingleNode ("/ root"); / / gets all the direct child nodes under the node XmlNodeList childlist=root.ChildNodes;// to determine whether there is a child node root.HasChildNodes under that node / / get a collection of peer nodes with the same name XmlNodeList nodelist=xml.SelectNodes ("/ Root/News"); / / generate a new node XmlElement node=xml.CreateElement ("News"); / / add a node to the specified node as its child node root.AppendChild (node); / / add the node to a child node under the specified node before root.InsertBefore (node,root.ChildeNodes [I]); / / assign the new attribute of the specified node and assign the value node.SetAttribute ("id", "11111") / / add a child node root.AppendChild (node) for the specified node; / / get the specified attribute value of the specified node string id=node.Attributes ["id"] .Value;// gets the text string content=node.InnerText;// in the specified node to save the XML file string path=Server.MapPath ("~ / file/bookstore.xml"); xml.Save (path); / / or use: xml.Save (HttpContext.Current.Server.MapPath ("~ / file/bookstore.xml")) Thank you for reading this article carefully. I hope the article ".net how to operate xml" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.