in reply to XML::LibXML question: How to list XInclude files, which are supposed to be included?

I've never used it or even heard of it, but a quick search of CPAN turns up XML::LibXML::Parser:
# Processing XInclude $parser->process_xincludes( $doc ); $parser->processXIncludes( $doc );
See the tests for an example of its usage.
  • Comment on Re: XML::LibXML question: How to list XInclude files, which are supposed to be included?
  • Download Code

Replies are listed 'Best First'.
Re^2: XML::LibXML question: How to list XInclude files, which are supposed to be included?
by AlexFromNJ (Novice) on Jul 06, 2011 at 17:16 UTC

    This will include all the content of XInclude files - I don't need that. I need a list of their filepaths

    Alex
      Can you just parse the include tag just like any other tag?

      I don't know how to use XML::LibXML, but this is simple using XML::Twig

      use warnings; use strict; use XML::Twig; my $myXML = <<EOF; <?xml version="1.0"?> <reports xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="xinclude.xml" parse='xml' /> </reports> EOF my $t = XML::Twig->new(twig_handlers => {'xi:include' => sub { print $ +_->att('href') } }); $t->parse($myXML); __END__ xinclude.xml

        Hum, something's not right because you use a prefix you never define.

        Yup, doesn't work :( It only finds one of the includes in

        <?xml version="1.0"?> <reports xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xinclude="http://www.w3.org/2001/XInclude"> <xi:include href="xinclude.xml" parse="xml" /> <xinclude:include href="xinclude.xml" parse="xml" /> <include xmlns="http://www.w3.org/2001/XInclude" href="xinclude.xml" p +arse="xml" /> </reports>

        I never used the XML::Twig... and it's not installed on my system now. It's big! but it might help though...

        I hoped to remain in the XML::LibXML realm actually

        Thanks

        Alex