How to read xml file to a string

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I have a xml file, say c:\book.xml;
How can I read the xml in that file to a string variable?
 
Hi,

Take a look at the StreamReader class, it has a member ReadToEnd().

Hope this helps
 
You can load it into an XML Document, then use InnerText method to retrieve
it.
I wouldn't use this method if you are not planning on actually using the XML
to do anything - loading into an XML Document causes it to be parsed.
If you aren't required to parse the XML, then just use standard file access
to open/read the file

Steve
 
Back
Top