Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: getting ancestors of element

by mertserger (Curate)
on Aug 31, 2012 at 09:12 UTC ( #990957=note: print w/ replies, xml ) Need Help??


in reply to getting ancestors of element

I would recommend mirod's site http://xmltwig.org/xmltwig/ as he is the author of XML::Twig. I find this section http://xmltwig.org/xmltwig/twig_stable.html particularly useful.

I think your code my @names = $twig->ancestors('values'); has two problems. Firstly it is actually looking for ancestors of the string itself (and there are none). You need to find every tag within the string and find theirancestors. Secondly you have an optional condition on the ancestors: the ('values') bit. This means you would only get ancestors called 'values'. If you want every ancestor, no condition is needed.


Comment on Re: getting ancestors of element
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2014-12-25 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls