From: VMI on
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.
From: Matthias Truxa on
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

"VMI" wrote:

> 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.
From: Martin Honnen on
VMI wrote:
> 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?

XDocument doc = XDocument.Parse(yourMethod());

Then use LINQ to XML to find/access nodes:
http://msdn.microsoft.com/en-us/library/bb387098.aspx

--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/