keyongtech


  keyongtech > dotnet.languages.* > dotnet.languages.csharp > 02/2010

 #1  
02-09-10, 02:18 PM
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.
 #2  
02-09-10, 02:52 PM
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

"VMI" wrote:
[..]
 #3  
02-09-10, 04:49 PM
Martin Honnen
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
Similar Threads
Parsing Variable string

Hi, I'm need to keep the first part of my variable and place the return value back to the save variable. Dim RevisedDate as String RevisedDate = "7/22/2009 3:19:52 PM" Now...

Easily parsing a string to retrieve values and assign them to a variable/symbol.

Hi! I've been looking in API's for a while in desperate need for an easy way to parse string and retrieve data (forget about Regexp or scanf), so that any non-rubyist guy I...

String parsing with variable lenght strings

I am trying to split up a cell into numbers and charachters and place them in separate columns, but the lenght of the number part varies as does the content of the character...

VB.NET - Parsing URL for Variable

Hi everyone, I am building a web crawler and one of the features which I need to include is exclusion of specified 'variable + value' from the url. Example, user wanted to...

Parsing the string, declaring the string by reference

Hi All, I am kind of new to Visual Basic and I have a generic question. I have a string with full addresses [I don't know how many addresses will be in the string, min = 2,...


All times are GMT. The time now is 06:12 AM. | Privacy Policy