I'm using XML::LibXML 1.66 and libxml2 2.6.26, to parse some XML that I would like to print the XML as it is read, without modification. When I run the following, all the entities are expanded...not what I want. Anyone know how to correct this?
#!/usr/bin/perl use strict; use XML::LibXML; my $fh = *DATA; my $parser = XML::LibXML->new(); $parser->expand_entities(0); my $doc = $parser->parse_fh( $fh ); my $root = $doc->getDocumentElement; my $format = 1; my $docencoding = 1; foreach my $xform_node ($root->findnodes('jobs/job')) { next if($xform_node->nodeType != &XML_ELEMENT_NODE); my $path = $xform_node->findvalue('info/directory'); my $xmlstring = $xform_node->toString($format,$docencoding); print "$path\n"; print "$xmlstring\n"; } __DATA__ <?xml version="1.0" encoding="UTF-8"?> <repository> <jobs> <job> <name>Screening</name> <directory>&#47;Biometrics&#47;TestCase</directory> <created_user>admin</created_user> <created_date>2007&#47;11&#47;29 15:29:07.000</created_date> <modified_user>admin</modified_user> <modified_date>2008&#47;02&#47;11 15:58:28.000</modified_date> </job> </jobs> </repository>

In reply to XML::LibXML expand_entities always expands entities by shamu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.