Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 0.42 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement