How to read xml file to a string

A

ad

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

Chris Taylor

Hi,

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

Hope this helps
 
S

Steve Lutz

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top