简单的XML操作

//把String 转成XML
string resultString = "<querycategory><name>GiftShops</name><score>0.36622</score><name>Wine</name><score>0.14643</score><name>CoffeeampTea</name><score>0.09771</score></querycategory>";
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(resultString);
        XmlElement root = doc.DocumentElement;
        XmlNodeList list = doc.DocumentElement.ChildNodes;
        string j = ((XmlElement)list[0]).InnerText;
        string k = ((XmlElement)list[1]).InnerText;
        Response.Write(j);
        Response.Write(k);

//将XML转成String
string path=Server.MapPath(null)+@"\my_phone.xml";
   XmlDocument table=new XmlDocument();
   table.Load(path);
   XmlNode root=table.DocumentElement;
   StringBuilder str=new StringBuilder();
   str.Append(root.OuterXml);

原文地址:https://www.cnblogs.com/liufei88866/p/937334.html