Get XML data and xml
Http://www.w3school.com.cn/xml/xml_elements.asp
<? Xml version = "1.0" encoding = "gb2312"?>
<String xmlns = "http://tempuri.org/"> 5/6/0:06:05 </string>
Obtain 5/6, 0:06:05 in the preceding XML
<?xml version="1.0" encoding="gb2312"?><string xmlns="http://tempuri.org/">200,2014/5/6 0:06:05</string>
Using System; using System. collections. generic; using System. linq; using System. text; using System. data. entity. validation; using System. data. entity; using System. data. objects; using System. web; using System. xml; namespace Test {class Program {static void Main (string [] args) {XmlDocument xml = new XmlDocument (); xml. load (".. /.. /1.xml"); // The XML file is loaded in, and the path is viewed. The relative path is used here. The XmlNode node = xml, which is definitely better than the path. lastChild; foreach (XmlNode item in node. childNodes) {Console. writeLine (item. innerXml); Console. writeLine (item. innerText); // string v = item. value; // node Value // string v1 = item. attributes ["xmlns"]. value; // node attribute Value. An error is returned when this parameter is obtained. The node data is incorrect and other XML data is required. // string v2 = item ["string"]. value; // element Value // string v3 = item ["string"]. attributes ["xmlns"]. value; // element property Value // Console. writeLine (v); // Console. writeLine (v1); // Console. writeLine (v2); // Console. writeLine (v3);} Console. readKey ();}}Get XML content XmlDocument xml = new XmlDocument () {InnerXml = @ "<? Xml version = '1. 0' encoding = 'gb2312 '?> <String xmlns = 'HTTP: // tempuri.org/'> 5/6/0:06:05 </string> "};Initialize XMLXmlDocument xml = new XmlDocument (); xml. LoadXml (@ "<? Xml version = '1. 0' encoding = 'gb2312 '?> <String xmlns = 'HTTP: // tempuri.org/'> 5/6/0:06:05 </string> "); Console. WriteLine (xml. InnerXml. ToString ());Initialize XML