I have been trying to search an XML File. I have tried several methods but I can't get it to populate the nodes. Here is an example of the code I've tried.
XmlDocument document = new XmlDocument();
document.Load(filename.xml);
XmlNodeList nodes = document.DocumentElement.SelectNodes("/reports/metadata]");
foreach (XmlNode node in nodes)
{
// Show Search results
}
document.Load(filename.xml);
XmlNodeList nodes = document.DocumentElement.SelectNodes("/reports/metadata]");
foreach (XmlNode node in nodes)
{
// Show Search results
}
Here is a sample file I'm trying to parse.
VulpesPosted Feb 11, 2014, 7:00 PM
Anyway, try this LINQ to XML code:
The output is:
This code, of course, only gets the metadata nodes which are children of the reports node - it doesn't get those nodes which are children of the files or file nodes.
Stephen MillerPosted Feb 12, 2014, 1:15 AM