Home > Net >  C # to parse the XML
C # to parse the XML

Time:01-22

After call interface, return XML, how to parse and remove the want to get to the value of the example below





Want to get to Quote serviceId and baseCharge and displayed, have to understand, to help explain it, thank you very much,

CodePudding user response:

 static void Main (string [] args) 
{

Var XML="& lt; EShipper XMLNS=\ version="http://www.eshipper.net/xml/XMLSchema" \ "3.0.0 " & gt; ";

XmlDocument xmlDoc=new XmlDocument ();

XmlDoc. LoadXml (XML);

XmlNodeList elemList=xmlDoc. GetElementsByTagName (" Quote ");
for (int i=0; I & lt; ElemList. Count; I++)
{
//serviceId
Console. WriteLine (elemList [I] Attributes. The GetNamedItem (" serviceId "). The Value).
//baseCharge
Console. WriteLine (elemList [I] Attributes. The GetNamedItem (" baseCharge "). The Value).
}

The Console. ReadKey ();
}
  •  Tags:  
  • C#
  • Related