views:

51

answers:

3

I want parse xml by looping through it. I referred this but I am not able to parse it using the Load function since it expects an URI parameter and not a string and so does LINQ to XML....Can anyone help me out ?

A: 
string recentFileName = Path.Combine(folderPath, filexml);
XDocument xDoc = XDocument.Load(recentFileName);
Martin Ongtangco
instead of using XmlDocument, use XDocument. xml-to-linq will be similar.
Martin Ongtangco
+2  A: 

XmlDocument has a Load method which takes a filename, but also a LoadXml method which takes a string:

http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.loadxml.aspx

Similarly, XDocument has a Load method which takes a filename, or a Parse method which takes a string:

http://msdn.microsoft.com/en-us/library/bb345532.aspx

Saxon Druce
A: 
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<root>" +
                    "<elem>some text<child/>more text</elem>" +
                    "</root>");
lukas