daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string myXml = "<test><a i=\"1\"/><a i=\"2\"/></a></a></test>";
  2. System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(myXml));
  3. System.Xml.XmlReader xr = System.Xml.XmlReader.Create(ms);
  4.  
  5. int firstIValue = 0;
  6.  
  7. while (xr.Read())
  8. {
  9.   if(xr.NodeType == System.Xml.XmlNodeType.Element)
  10.     if (xr.Name == "a")
  11.     {
  12.       firstIValue = Convert.ToInt32(xr["i"]);
  13.       break;
  14.     }
  15. }
RAW Paste Data
Top