Jump to content

extract attribute value in xpath


Guest chetrity

Recommended Posts

Guest chetrity

hi,simple question I guess but I couldn't find the answer...How to extract the value of an attribute using xPath?for example, lets say this is the xml:<root> <classes> <class> <lesson id="55" /> <lesson id="66" /> <lesson id="88" /> </class > </classes></root>and I want the output to be :556688so the path should be: ...xmlDoc.selectNodes(/classes/class/lesson/???)and I dont know what should be instead of the ???(@id will bring back: id="55" while I need only 55)Thanks

Link to comment
Share on other sites

How about enclosing the whole expression in a string function like this:

xmlDoc.selectNodes(string(/root/classes/class/lesson/@id))

Or perhaps there is another object to select only the content of the targeted element?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...