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

Which Perl Module would you recommend I use to get this done? I tried each of the suggested forms and each returned an unexpected element.
<xsl:for-each select='/PLMXML/Form[@id=&apos;id24&apos;]'> <xsl:value-of select="@id"/> </xsl:for-each> returns: id36 <xsl:for-each select="/PLMXML/Form[@id=&quot;id24&quot;]"> <xsl:value-of select="@id"/> </xsl:for-each> returns: id36 <xsl:for-each select='/PLMXML/Form[@id="id24"]'> <xsl:value-of select="@id"/> </xsl:for-each> returns: id36 <xsl:for-each select="/PLMXML/Form[@id='id24']"> <xsl:value-of select="@id"/> </xsl:for-each> returns: id36

Replies are listed 'Best First'.
Re^3: xml::xslt xpath bug?
by ikegami (Patriarch) on Jul 07, 2009 at 16:32 UTC
    Sorry, I can't make a recommendation. I've never used XSLT.
      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).
        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.