I’d like to get all the element XPaths from a xml file, for example the xml file is,
something like when you open an XML file with Excel
<BookStore>
<BookStoreInfo>
<Address />
<Tel />
<Fax />
<BookStoreInfo>
<Book id="123" category="Science Fiction">
<BookName />
<ISBN />
<PublishDate />
</Book>
<Book>
....
</Book>
</BookStore>
I would like to get
BookStore/BookStoreInfo/Address
BookStore/BookStoreInfo/Tel
BookStore/BookStoreInfo/Fax
BookStore/Book/@id
BookStore/Book/@category
BookStore/Book/BookName
BookStore/Book/ISBN
BookStore/Book/PublishDate
I tried several ways, but doesn’t work, how can I do it?
You could load the xml into an XmlDocument and traverse through the tree until you hit a node with no children building up a string as you go and repeat.
Did a quick google to find you an example and found this right here on stackoverflow