Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How can I browse & list XPATH of a XML Message?

by choroba (Cardinal)
on Oct 30, 2015 at 03:01 UTC ( [id://1146440]=note: print w/replies, xml ) Need Help??


in reply to How can I browse & list XPATH of a XML Message?

Pretty easy in XML::XSH2, a wrapper around XML::LibXML:
open file.xml ; for ( /descendant-or-self::node() | //@* ) echo xsh:path(.) (.) ;

To skip double reports for text() nodes and non-leaf nodes, you can add

[not(./*)][not(self::text())]

after the node().

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: How can I browse & list XPATH of a XML Message?
by Anonymous Monk on Oct 30, 2015 at 06:32 UTC

     [not(./*)][not(self::text())]

    thats xsh syntax? what is equivalent xpath syntax?

      No, that's standard XPath syntax. What made you think it's not?
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        the stacking  [][] and maybe (if thats what you meant) starting with  []
        can you explain it in plain English?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found