Getting all contents from XMLReader into string?

  • Thread starter Thread starter SamIAm
  • Start date Start date
S

SamIAm

Is there a way to do this without looping through all the nodes using read()

I need to return the contents of the reader as a string

Thanks

S
 
You can try something like

StreamReader sr = new StreamReader(s);
transForm.Load(new XmlTextReader(new StringReader(sr.ReadToEnd())));

Thats just a snippted to load in an .xsl file but you can use the same
approach. Use .ReadToEnd() and pass that to your string to hold the data.

XmlDocument.Load simply loads in the entire XML file into memory which
then you can convert .ToString() as well.
 
Back
Top