Hello Lindsay,
If you already have the XML in a string format, then you can use the
InnerText property of the XmlDocument to create a DOM Tree. In the example
below, I have a string which contains the xml. I contruct a DOM Tree and
parse its attributes.
using System;
using System.IO;
using System.Xml;
public class XmlFromString
{
public static void Main(string[] args)
{
string xml = "<?xml version='1.0'?><person firstname='john'
lastname='smith' />";
XmlDocument doc = new XmlDocument();
doc.InnerXml = xml;
XmlElement root = doc.DocumentElement;
Console.WriteLine(" The firstname : {0} lastname: {1}",
root.GetAttribute("firstname"), root.GetAttribute("lastname"));
}
}
regards,
Abhishek.
"Lindsay" <do_not_email_me@i_hate_spam.com> wrote in message
news:#6**************@TK2MSFTNGP10.phx.gbl...
I'm new to C# from a C++ background.
A problem I'm having is getting my head around the different XML classes
available.
In particular I have a String type containing XML and want to parse it to
extract values. The XML classes I've seen so far will do it from a file or
a stream but (unless my eyes have failed) I can't find one to do it directly
from a String.
Any help appreciated!
Lindsay