Get xpath of current Node?
-
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
-
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
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