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

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
  • Comment on Re^3: XML::LibXML question: How to list XInclude files, which are supposed to be included?
  • Download Code

Replies are listed 'Best First'.
Re^4: XML::LibXML question: How to list XInclude files, which are supposed to be included?
by ikegami (Patriarch) on Jul 06, 2011 at 18:39 UTC

    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>
Re^4: XML::LibXML question: How to list XInclude files, which are supposed to be included?
by AlexFromNJ (Novice) on Jul 06, 2011 at 18:41 UTC

    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

      The Swiss Army Knife® of XML in Perl ... IMHO ... is a twig.