Parse an xml string.

Parse an xml string.

Post by Mark Moeyken » Sun, 17 Mar 2002 04:40:15



Hi Everyone,

I have a web service that returns an xml string like this:
<USERS UserID="1" FirstName="Mark" LastName="Moeykens" CompanyName="Mark
Moeykens, Inc."/>

What is the best way to break this string apart to get the values out of it?

Thanks,
Mark Moeykens

 
 
 

Parse an xml string.

Post by MSFT » Sun, 17 Mar 2002 07:28:21


You can wrap it into <?xml ...><root></root>, effectively creating a simple
XML document. Then you can feed the result to the XmlReader and access
attribute/values via DOM.


Quote:> Hi Everyone,

> I have a web service that returns an xml string like this:
> <USERS UserID="1" FirstName="Mark" LastName="Moeykens" CompanyName="Mark
> Moeykens, Inc."/>

> What is the best way to break this string apart to get the values out of
it?

> Thanks,
> Mark Moeykens


 
 
 

1. C# - parsing an XML string

Hello,

I am developing in Visual Studio .NET 2005.  I am attempting to parse
an XML string by using the example given in the help files:

ms-help://MS.VSCC.v80/MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref/html/M_System_Xml_XmlReader_Create_1_6b76289f.htm

namely,

string xmlData ="<item productID='124390'>" +
                        "<price>5.95</price>" +
                        "</item>";

// Create the XmlReader object.
XmlReader reader = XmlReader.Create(new StringReader(xmlData));

However, when I attempt to actually parse this string by

reader.ReadStartElement("item");
string productID = reader.GetAttribute("productID");

I just get null for productID.  Can anyone see what I am doing wrong?

Thanks,
Don

2. Razor still cutting?

3. Parse an xml string.

4. lpr-switches and .xemacs-options problem

5. How to Parse Xml String in DotNet 2003 C#.

6. VT100 emulator

7. Newbie... Parse String into A XML Schema/dataset

8. (no subject)

9. Xml Parsing Error sending valid Xml to stored procedure from ADO.Net / C#

10. 2 x xml parse to 1 xml

11. System.Xml.XmlTextReader.ParseRoot() error when reading xml file from treenode TreeNodeSrc

12. XmlReader to an XML string and then return the string

13. String Parsing the .NET way.