Parsing XML in string variable?

V

VMI

I have a method that returns a string that contains XML, and I need to parse
that string (ie. find specific keys).

How can I do this? I found one that searches a Stream, but I don't know how
to convert from string to stream.

Thanks.
 
M

Matthias Truxa

hi vmi,

you could use the System.Xml.XmlDocument class, simply make a new instance
and use the LoadXml-Method (does not properly load string with encoding
markers).
You could also use the .NET 3.5 System.Xml.Linq.XElement.
There are several utility classes to read from strings and streams and vice
versa, e.g. System.IO.StringReader & StreamReader, which are derived from
TextReader.
You need to experiment a little and look at their constructors to find what
you need, or you have to post exactly what you want and (hopefully) find
someone to complete the code.

Regards,
Matt
 

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