Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Turns out that XML::LibXML can do the work for you at the cost of flexibility:
use strict; use warnings; use XML::LibXML qw( ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_fh(*STDIN); my $root = $doc->documentElement(); for my $node ($root->findnodes('//*')) { print($node->nodePath(), ': ', $node->nodeName(), "\n"); }
/*: OTA_AirSeatMapRS /*/*[1]: Success /*/*[2]: SeatMapResponses /*/*[2]/*[1]: SeatMapResponse /*/*[2]/*[1]/*[1]: FlightSegmentInfo /*/*[2]/*[1]/*[1]/*[1]: DepartureAirport /*/*[2]/*[1]/*[1]/*[2]: ArrivalAirport /*/*[2]/*[1]/*[1]/*[3]: OperatingAirline /*/*[2]/*[1]/*[1]/*[4]: MarketingAirline /*/*[2]/*[1]/*[2]: SeatMapDetails /*/*[2]/*[1]/*[2]/*: CabinClass /*/*[2]/*[1]/*[2]/*/*: AirRows /*/*[2]/*[1]/*[2]/*/*/*[1]: AirRow /*/*[2]/*[1]/*[2]/*/*/*[1]/*[1]: AirSeats /*/*[2]/*[1]/*[2]/*/*/*[1]/*[1]/*[1]: AirSeat /*/*[2]/*[1]/*[2]/*/*/*[1]/*[1]/*[2]: AirSeat /*/*[2]/*[1]/*[2]/*/*/*[1]/*[1]/*[3]: AirSeat /*/*[2]/*[1]/*[2]/*/*/*[1]/*[1]/*[4]: AirSeat /*/*[2]/*[1]/*[2]/*/*/*[1]/*[1]/*[5]: AirSeat /*/*[2]/*[1]/*[2]/*/*/*[1]/*[1]/*[6]: AirSeat /*/*[2]/*[1]/*[2]/*/*/*[1]/*[2]: AirRowCharacteristics /*/*[2]/*[1]/*[2]/*/*/*[2]: AirRow /*/*[2]/*[1]/*[2]/*/*/*[2]/*[1]: AirSeats /*/*[2]/*[1]/*[2]/*/*/*[2]/*[1]/*[1]: AirSeat /*/*[2]/*[1]/*[2]/*/*/*[2]/*[1]/*[2]: AirSeat ... /*/*[2]/*[2]/*[2]/*/*/*[21]/*[1]/*[5]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[21]/*[1]/*[6]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[21]/*[2]: AirRowCharacteristics /*/*[2]/*[2]/*[2]/*/*/*[22]: AirRow /*/*[2]/*[2]/*[2]/*/*/*[22]/*[1]: AirSeats /*/*[2]/*[2]/*[2]/*/*/*[22]/*[1]/*[1]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[22]/*[1]/*[2]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[22]/*[1]/*[3]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[22]/*[1]/*[4]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[22]/*[1]/*[5]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[22]/*[1]/*[6]: AirSeat /*/*[2]/*[2]/*[2]/*/*/*[22]/*[2]: AirRowCharacteristics /*/*[2]/*[2]/*[3]: BookingReferenceID /*/*[2]/*[3]: AirTravelers /*/*[2]/*[3]/*[1]: AirTraveler /*/*[2]/*[3]/*[1]/*[1]: PersonName /*/*[2]/*[3]/*[1]/*[1]/*[1]: GivenName /*/*[2]/*[3]/*[1]/*[1]/*[2]: MiddleName /*/*[2]/*[3]/*[1]/*[1]/*[3]: Surname /*/*[2]/*[3]/*[1]/*[1]/*[4]: NameTitle /*/*[2]/*[3]/*[1]/*[2]: TravelerRefNumber /*/*[2]/*[3]/*[2]: AirTraveler /*/*[2]/*[3]/*[2]/*[1]: PersonName /*/*[2]/*[3]/*[2]/*[1]/*[1]: GivenName /*/*[2]/*[3]/*[2]/*[1]/*[2]: MiddleName /*/*[2]/*[3]/*[2]/*[1]/*[3]: Surname /*/*[2]/*[3]/*[2]/*[1]/*[4]: NameTitle /*/*[2]/*[3]/*[2]/*[2]: TravelerRefNumber /*/*[2]/*[3]/*[3]: AirTraveler /*/*[2]/*[3]/*[3]/*[1]: PersonName /*/*[2]/*[3]/*[3]/*[1]/*[1]: GivenName /*/*[2]/*[3]/*[3]/*[1]/*[2]: MiddleName /*/*[2]/*[3]/*[3]/*[1]/*[3]: Surname /*/*[2]/*[3]/*[3]/*[1]/*[4]: NameTitle /*/*[2]/*[3]/*[3]/*[2]: TravelerRefNumber

In reply to Re: XPATH DOM traverse html/xml (->nodePath) by ikegami
in thread XPATH DOM traverse html/xml by gsiglet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2014-09-20 05:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (153 votes), past polls