Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Anonymous Monk
on Jun 30, 2013 at 04:15 UTC ( [id://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" ) ) ]

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1041544]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found