Global variable m_xDoc
I have a property of
public XmlDocument xDoc { get {return m_xDoc; } set {value = m_xDoc; } } string xml = "<head><body><Inner> welcome </head></Inner><Outer> Bye</Outer></body></head>"
Now I have to set that property with this string as XML document ... please guide me how to do this
XDocument is from the LINQ to XML API, and XmlDocument is the standard DOM-style API for XML. If you know DOM well, and don't want to learn LINQ to XML, go with XmlDocument . If you're new to both, check out this page that compares the two, and pick which one you like the looks of better.
Use LoadXml Method of XmlDocument;
string xml = "<head><body><Inner> welcome </head> </Inner> <Outer> Bye</Outer></body></head>"; xDoc.LoadXml(xml);
// using System.Xml; String rawXml = @"<root> <person firstname=""Riley"" lastname=""Scott"" /> <person firstname=""Thomas"" lastname=""Scott"" /> </root>"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(rawXml);
I think this should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With