TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Stephen Miller
NA
10
0
Searching XML Nodes
Feb 11 2014 5:29 PM
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
}
Here is a sample file I'm trying to parse.
<?xml version="1.0" encoding="utf-8"?>
<reports id="fa34b14287d4" name="analysis" version="4.0" xmlns="http://www.awebsite.com/reports">
<metadata section="Additional Fields">
<item name="Report Number"><![CDATA[REPORT NUMBER]]></item>
<item name="Department"><![CDATA[DEPARTMENT]]></item>
<item name="Unit"><![CDATA[UNIT]]></item>
<item name="name"><![CDATA[NAME]]></item>
<item name="Location" />
</metadata>
<metadata section="Report Data">
<item name="start date/time"><![CDATA[2014-01-28T11:51:27]]></item>
<item name="end date/time"><![CDATA[2014-01-28T12:05:06]]></item>
<item name="Identifier"><![CDATA[4662]]></item>
<item name="Version"><![CDATA[Software: 1.33]]></item>
<item name="Report type"><![CDATA[Full]]></item>
</metadata>
<Files>
<file filename="00001.doc" path="/data/reports/" size="20480" id="71115592">
<accessInfo>
<timestamp name="ModifyTime">2014-01-21T20:28:06+00:00</timestamp>
</accessInfo>
<metadata section="File">
<item name="Local Path"><![CDATA[files\reports\]]></item>
<item name="SHA256"><![CDATA[7746d684eabb94a62a9c6777907ba57dcd1fda51f01874de8455553a5dc26d6b]]></item>
<item name="MD5"><![CDATA[]]></item>
<item name="Tags"><![CDATA[Database]]></item>
</metadata>
</file>
<file filename="00002.doc" path="/data/reports/" size="237568" id="69dc40be4ac7">
<accessInfo>
<timestamp name="ModifyTime">2014-01-22T18:01:34+00:00</timestamp>
</accessInfo>
<metadata section="File">
<item name="Local Path"><![CDATA[files\reports]]></item>
<item name="SHA256"><![CDATA[1bdff5e407a081a529aa2da386976db5698875eb358870e776038dd359bdbaf9]]></item>
<item name="MD5"><![CDATA[]]></item>
<item name="Tags"><![CDATA[Database]]></item>
</metadata>
</file>
</Files>
</reports>
Reply
Answers (
2
)
Nested Loops problem
language