954,148 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Xpath navigation in xml file

hi all,
i have the following xml file.

SWF mediahttp://www.blogdigger.com/media/
Recent .swf files found by BlogdiggerDollar Bus Rolls Into Townhttp://feeds.feedburner.com/Chicagoist?m=1115
some descriptionThu, 23 Mar 2006 14:11:57 ESTE-mailhttp://billarnold.typepad.com/poet_in_motion/2006/03/email.html
description 2/description>
Wed, 22 Mar 2006 17:28:28 EST

i am using xpath to navigate through this xml file.
i used the following code to navigate through items node.

XmlDocument doc = new XmlDocument();
doc.Load(xmlfile);

XPathNavigator nav = doc.CreateNavigator();
XPathExpression exp = nav.Compile("rss/channel/item");

XPathNodeIterator iterator = nav.Select(exp);
XPathNodeIterator iter1;
while (iterator.MoveNext())
{
iter1 = iterator.Current.SelectChildren("media:content", "");
if (iter1.Count > 0)
{
while (iter1.MoveNext())
{
if (iter1.Current.HasAttributes == true)
{
string url = iter1.Current.GetAttribute("url", "");
}
}
}
}

but when i execute the code, the iter1.count always returns zero. if i select anyother children(like title or description)i am able to display the value.but when i select media:content(one of the subitems of item) i am not able to display the attribute value.

Where am i going wrong?

Any suggestions please

regards

Exelio

Exelio
Junior Poster in Training
57 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

hi guys,

i solved it by myself. for everybody's reference,

iter1 = iterator.Current.SelectChildren("content", "http://tools.search.yahoo.com/mrss/");

i need to include the namespace URI in the selectchildren method and it worked.

Thanks

Regards

Exelio

Exelio
Junior Poster in Training
57 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You