Main Site Documentation

XmlReader


#1

Hi all, Is there a way to use XmlReader with a string containing the XML document ?


#2

Yes,

You can put string into a stream and use the stream object with XmlReader.


#3

Create the XmlReader from a Stream object like so:

 
      string s = "Some valid XML";
      byte[] bytes = Encoding.UTF8.GetBytes (s);
      MemoryStream ms = new MemoryStream (bytes);
      XmlReader reader = XmlReader.Create(stream); 

Word of warning - XML is a memory hog and you can quickly eat up all the smaller FEZ boards have to offer.


#4

Thanks you very much guys


#5

I used XML as well in the past. I now moved to JSON, feels much lighter :wink:


#6

Json makes it easier for javascript to parse. Xml is still a better choice if you want something universal.