in reply to Re^3: xml::xslt xpath bug?
in thread xml::xslt xpath bug?

Okay, a more general question. What Perl Module(s) would you use to get bits of information out of an xml file and put them into an Excel file? I tried XML::Parser but found it dropped lots of data when it read xml into an array (and I had the same problem when I tried read xml into a hash).

Replies are listed 'Best First'.
Re^5: xml::xslt xpath bug?
by ikegami (Patriarch) on Jul 07, 2009 at 16:48 UTC
    I use XML::LibXML to do my XML parsing (fastest I've found, very complete, very reliable, clean interface), and I use XPaths (via findnodes) to extract data from the resulting tree.

    Example:

    my @forms = $xpc->findnodes('/plm:PLMXML/plm:Form'); for my $form (@forms) { print( $form->getAttribute('subClass'), "\n" ); ... }

    Example:

    my ($form) = $xpc->findnodes( '/plm:PLMXML/plm:Form[subClass="Part Revision Master"]' ) or die("Can't find Part Revision Master form\n"); print($form->getAttribute('id'), "\n"); # id24

    Update: Added examples.
    Update: Fixed examples.