Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Get Node Value from irregular XML (xpather.pl)

by Anonymous Monk
on Jun 30, 2013 at 04:15 UTC ( #1041544=note: print w/ replies, xml ) Need Help??


in reply to Get Node Value from irregular XML

If you run xpather.pl -a yourfile.xml you'll see

# posy /root[1]/part[1]/sect[1]/header[1] # star /*[ name() = "root" and position() = 1 ] /*[ name() = "part" and position() = 1 ] /*[ name() = "sect" and position() = 1 ] /*[ name() = "header" and position() = 1 ] # "content" This is a design XZY document for Project

Just like position() there is also contains() , so you can use

//*[ ( name() = "para" or name() = "header" ) and ( not(descendant::*) ) and ( contains( translate( ., "DESIGN", "design", ), "design" ) ) ]


Comment on Re: Get Node Value from irregular XML (xpather.pl)
Select or Download Code
Re^2: Get Node Value from irregular XML (xpather.pl)
by Anonymous Monk on Jun 30, 2013 at 04:41 UTC

    Hmm, libxml seems to not like double quotes, weird, this version tested

    //*[ ( name() = 'para' or name() = 'header' ) and ( not(descendant::*) ) and ( contains( translate( ., 'DESIGN', 'design' ), 'design' ) ) ]

      Hmm, libxml seems to not like double quotes, weird, this version tested

      Nope, it likes double quotes just fine, I got tripped by by win32 system limitations

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-09-01 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (14 votes), past polls