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. Visual Basic
  4. XPath problem

XPath problem

Scheduled Pinned Locked Moved Visual Basic
xmlhtmlwcfjsonhelp
3 Posts 2 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.
  • R Offline
    R Offline
    raf franco
    wrote on last edited by
    #1

    Hi, I have a problem parsing a WSDL xml with an XMlDocument. This is a short version of the XML: The code I use is: Dim dom As New System.Xml.XmlDocument dom.Load(URL.Text) 'Create an XmlNamespaceManager for resolving namespaces. Dim nsmgr As System.Xml.XmlNamespaceManager = _ New System.Xml.XmlNamespaceManager(dom.NameTable) For Each att As System.Xml.XmlAttribute In dom.DocumentElement.Attributes If att.Prefix = "xmlns" Then nsmgr.AddNamespace(att.LocalName, att.Value) End If If att.LocalName = "xmlns" Then nsmgr.AddNamespace("", att.Value) End If Next When I use the commandwindow for selecting the service element I get: >? dom.selectsinglenode("./node()[1]/service",nsmgr) Nothing But the statement below gives >? dom.selectsinglenode("./node()[1]/node()[8]",nsmgr) {System.Xml.XmlElement} [System.Xml.XmlElement]: {System.Xml.XmlElement} Attributes: {System.Xml.XmlAttributeCollection} BaseURI: "http://localhost/webreferenceaddin.defaultcustomer/customerengine.asmx?wsdl" ChildNodes: {System.Xml.XmlChildNodes} FirstChild: {System.Xml.XmlElement} HasChildNodes: True InnerText: "" InnerXml: "

    J 1 Reply Last reply
    0
    • R raf franco

      Hi, I have a problem parsing a WSDL xml with an XMlDocument. This is a short version of the XML: The code I use is: Dim dom As New System.Xml.XmlDocument dom.Load(URL.Text) 'Create an XmlNamespaceManager for resolving namespaces. Dim nsmgr As System.Xml.XmlNamespaceManager = _ New System.Xml.XmlNamespaceManager(dom.NameTable) For Each att As System.Xml.XmlAttribute In dom.DocumentElement.Attributes If att.Prefix = "xmlns" Then nsmgr.AddNamespace(att.LocalName, att.Value) End If If att.LocalName = "xmlns" Then nsmgr.AddNamespace("", att.Value) End If Next When I use the commandwindow for selecting the service element I get: >? dom.selectsinglenode("./node()[1]/service",nsmgr) Nothing But the statement below gives >? dom.selectsinglenode("./node()[1]/node()[8]",nsmgr) {System.Xml.XmlElement} [System.Xml.XmlElement]: {System.Xml.XmlElement} Attributes: {System.Xml.XmlAttributeCollection} BaseURI: "http://localhost/webreferenceaddin.defaultcustomer/customerengine.asmx?wsdl" ChildNodes: {System.Xml.XmlChildNodes} FirstChild: {System.Xml.XmlElement} HasChildNodes: True InnerText: "" InnerXml: "

      J Offline
      J Offline
      Jan Tielens
      wrote on last edited by
      #2

      Hi Raf! You could use following XPath query: node()[1]/*[name()='service'] For a good overview of all XPath possiblities (including interactive testing!), visit http://www.zvon.org/xxl/XPathTutorial/General/examples.html. To do some more interactive testing you can use the XPath Visualizer Version 1.4 (http://www.vbxml.com/xpathvisualizer/default.asp). Greetz Jan

      R 1 Reply Last reply
      0
      • J Jan Tielens

        Hi Raf! You could use following XPath query: node()[1]/*[name()='service'] For a good overview of all XPath possiblities (including interactive testing!), visit http://www.zvon.org/xxl/XPathTutorial/General/examples.html. To do some more interactive testing you can use the XPath Visualizer Version 1.4 (http://www.vbxml.com/xpathvisualizer/default.asp). Greetz Jan

        R Offline
        R Offline
        raf franco
        wrote on last edited by
        #3

        Thank you for the solution. It works. I will check the site later this week. Raf.

        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