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. C#
  4. Get xpath of current Node?

Get xpath of current Node?

Scheduled Pinned Locked Moved C#
htmldata-structuresxmlquestionlearning
2 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.
  • B Offline
    B Offline
    Bog
    wrote on last edited by
    #1

    I have an XPathNodeIterator and I've been crawling through an dom tree reading in information. What I want to do is, given a node or attribute, I want an xpath expression that refers to that node. So in other words, the opposite of XPathNavigator.Evaluate(). I want a method that takes a node and returns a string that says "/html/body/table[2]/tr[4]/td" Is there anything built in like that? making it myself would be a pain. "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

    C 1 Reply Last reply
    0
    • B Bog

      I have an XPathNodeIterator and I've been crawling through an dom tree reading in information. What I want to do is, given a node or attribute, I want an xpath expression that refers to that node. So in other words, the opposite of XPathNavigator.Evaluate(). I want a method that takes a node and returns a string that says "/html/body/table[2]/tr[4]/td" Is there anything built in like that? making it myself would be a pain. "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Not that I know of. You can iterate backwards through the document and build /html/body/table/tr/td but to get the index, you'd have to iterate through the children at the same level, and try to figure out which was yours. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma Anonymous wrote: OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window. I think you are a good candidate for Visual Basic. - Nemanja Trifunovic

      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