Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Regarding xpath expressions

Regarding xpath expressions

Scheduled Pinned Locked Moved XML / XSL
xmlhtmlcomquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anu81
    wrote on last edited by
    #1

    hi all, i have the following xml file. SWF media http://www.blogdigger.com/media/ Recent .swf files found by Blogdigger Dollar Bus Rolls Into Town http://feeds.feedburner.com/Chicagoist?m=1115 some description Thu, 23 Mar 2006 14:11:57 EST E-mail http://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 Thanks in advance.:) Regards Anuradha

    A 1 Reply Last reply
    0
    • A anu81

      hi all, i have the following xml file. SWF media http://www.blogdigger.com/media/ Recent .swf files found by Blogdigger Dollar Bus Rolls Into Town http://feeds.feedburner.com/Chicagoist?m=1115 some description Thu, 23 Mar 2006 14:11:57 EST E-mail http://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 Thanks in advance.:) Regards Anuradha

      A Offline
      A Offline
      anu81
      wrote on last edited by
      #2

      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 Anu

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups