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. A stranger question about Selectsinglenode method

A stranger question about Selectsinglenode method

Scheduled Pinned Locked Moved Visual Basic
xmlquestion
1 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.
  • S Offline
    S Offline
    sanyexian
    wrote on last edited by
    #1

    Hello,everyone! Now I use the method "selectsinglenode" with xpath to search in my XML, I find a stranger question.In my project, when I used this method at first, it didn't get the node that I wanted, so I created a new project to try the xpath, it could got the node now.(The same xpath and same XML file) Then I deleted some controls in my project which was about the method(not the new one), create new, then the method could find the node! I can't understand it, same xpath, same function,same value,why it happens?:confused::confused: Hope some one could tell me the reason and give me some suggestion!Thank you! The function that I used to search a node was like below:

    Dim val As String = ""
    Dim xmldoc As New XmlDocument()
    Dim xpath As String
    Try
    xmldoc.Load(Application.StartupPath + "\Flange\Nozzle-Flange-Height.xml")
    Dim xmlnode As XmlNode
    If Not (Standard = "") Then
    xpath = "/Nozzle-Flange-Height/Standard[@value='" + Standard + "']/Flange-type[@type='" + Type + "']/PN[@PN='" + PN + "']/Height[@DN='" + DN + "']"
    xmlnode = xmldoc.SelectSingleNode(xpath)
    If Not xmlnode Is Nothing Then
    val = xmlnode.InnerText
    Else
    MsgBox("Could not find!")
    End If
    Else
    val = ""
    MsgBox("Input by yourself!")
    End If
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    Return val

    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