in reply to Duplicate entries with nested xml

Try this:

use strict; use warnings; use XML::LibXML; my $file = qq(appsimage_EBSB4.xml); open my $fh, '<', $file; binmode $fh; my $doc = XML::LibXML->load_xml(IO => $fh); close $fh; print $doc->toString(); __END__ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE clone [ <!ENTITY envPageConfig SYSTEM "./envPageConfig.xml"> ]> <clone-config> <comt4> <bolinfpwd>welcome</bolinfpwd> </comt4> </clone-config>

Edit: forgot my $doc :-(

Please note: your entity should be written as &envPageConfig;, not "&envPageConfig";.

Update:

This might be helpful too:

use strict; use warnings; use XML::Twig; use Data::Dumper; my $file = qq(appsimage_EBSB4.xml); my $hash_ref = XML::Twig->new()->parsefile( $file )->simplify(); print Dumper($hash_ref); print $hash_ref->{comt4}->{bolinfpwd};

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re^2: Duplicate entries with nested xml
by tobyink (Canon) on Sep 04, 2014 at 16:38 UTC

    This part:

    my $file = qq(appsimage_EBSB4.xml); open my $fh, '<', $file; binmode $fh; my $doc = XML::LibXML->load_xml(IO => $fh); close $fh;

    Could be written more succinctly as:

    my $doc = XML::LibXML->load_xml( location => qq(appsimage_EBSB4.xml) +);
      "...written more succinctly..."

      Sure tobyink, nothing but the truth. I didn't know this.

      To be honest: I'm still using XML::Simple :-[ because i got a lot of config stuff written with it and cheated my example from the docs of XML::LibXML.

      N.B.: I also tried XML::LibXML::Simple with the stuff the OP provided, but it failed with the entity...

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        XML::Rules will provide an easy way forward. Using the DTD or a few examples it can infer rules that'll instruct the parser to produce data structure equivalent to a well set XML::Simple and at the same time allow you to start tweaking and trimming the structure to better fit your needs.

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.