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. Web Development
  3. ASP.NET
  4. XPath not working with xmlns attribute

XPath not working with xmlns attribute

Scheduled Pinned Locked Moved ASP.NET
helpxmlasp-netquestion
4 Posts 3 Posters 1 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.
  • H Offline
    H Offline
    Hari 2009
    wrote on last edited by
    #1

    I have an xml file and I am trying to use selectnodes with an xpath expression which is not working. After trial and error I found that the xml file has this rootnode <batchRequest onError="exit" xmlns="urn:oasis:names:tc:DSML:2:0:core"> and it is getting thrown off with the attribute xmlns. If I remove the xmlns attribute the xpath works fine. The xml file is a DSML message that I am receiving from another application. Is this a bug or some limitation of the xpath? Does xpath has any limitations when it sees an xmlns attribute? Can any one suggest a workaround with this problem.

    G J 2 Replies Last reply
    0
    • H Hari 2009

      I have an xml file and I am trying to use selectnodes with an xpath expression which is not working. After trial and error I found that the xml file has this rootnode <batchRequest onError="exit" xmlns="urn:oasis:names:tc:DSML:2:0:core"> and it is getting thrown off with the attribute xmlns. If I remove the xmlns attribute the xpath works fine. The xml file is a DSML message that I am receiving from another application. Is this a bug or some limitation of the xpath? Does xpath has any limitations when it sees an xmlns attribute? Can any one suggest a workaround with this problem.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Please don't cross post. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • H Hari 2009

        I have an xml file and I am trying to use selectnodes with an xpath expression which is not working. After trial and error I found that the xml file has this rootnode <batchRequest onError="exit" xmlns="urn:oasis:names:tc:DSML:2:0:core"> and it is getting thrown off with the attribute xmlns. If I remove the xmlns attribute the xpath works fine. The xml file is a DSML message that I am receiving from another application. Is this a bug or some limitation of the xpath? Does xpath has any limitations when it sees an xmlns attribute? Can any one suggest a workaround with this problem.

        J Offline
        J Offline
        jcrussell
        wrote on last edited by
        #3

        you have to use a namespacemanager. xmlns stands for XML Namespace. Once you add the value to the namespacemanager then you can use xpath.

        dim namespaceManager as XmlNamespaceManager 
        namespaceManager = new XmlNamespaceManager(xmlDocument.NameTable)
        namespaceManager.AddNamespace("oasis", "urn:oasis:names:tc:DSML:2:0:core")
        

        Then when you use xPath, you have to use your custom namespacemanager, and everything should work fine. Jason

        H 1 Reply Last reply
        0
        • J jcrussell

          you have to use a namespacemanager. xmlns stands for XML Namespace. Once you add the value to the namespacemanager then you can use xpath.

          dim namespaceManager as XmlNamespaceManager 
          namespaceManager = new XmlNamespaceManager(xmlDocument.NameTable)
          namespaceManager.AddNamespace("oasis", "urn:oasis:names:tc:DSML:2:0:core")
          

          Then when you use xPath, you have to use your custom namespacemanager, and everything should work fine. Jason

          H Offline
          H Offline
          Hari 2009
          wrote on last edited by
          #4

          Thank you Jason for your reply.

          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