Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Want to fetch inner most child element first

by sundialsvc4 (Abbot)
on Sep 23, 2015 at 17:52 UTC ( [id://1142831]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Want to fetch inner most child element first
in thread Want to fetch inner most child element first

The XPath expression that you have written merely matches the outermost node.   What you might want to use here are axes.

Try something like this:   (extemporaneous answer, check it yourself)

//xml:msub[count(descendant::xml:msub) = 0] to retrieve all msubs who do not have any descendants of the same type.   These must be the leaves of the structure.

Now, for each of these, perform a separate query for ancestor::xml:msub which will return an ordered list (from closest to farthest, or is it the other way around?) of all ancestors back to the top of the tree.

  • Comment on Re^3: Want to fetch inner most child element first

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1142831]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-16 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found