shamu has asked for the wisdom of the Perl Monks concerning the following question:
#!/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>/Biometrics/TestCase</directory> <created_user>admin</created_user> <created_date>2007/11/29 15:29:07.000</created_date> <modified_user>admin</modified_user> <modified_date>2008/02/11 15:58:28.000</modified_date> </job> </jobs> </repository>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::LibXML expand_entities always expands entities
by pc88mxer (Vicar) on May 14, 2008 at 16:26 UTC | |
by shamu (Acolyte) on May 14, 2008 at 16:54 UTC | |
by shamu (Acolyte) on May 14, 2008 at 16:54 UTC | |
|
Re: XML::LibXML expand_entities always expands entities
by ikegami (Patriarch) on May 14, 2008 at 17:15 UTC | |
by shamu (Acolyte) on May 14, 2008 at 17:22 UTC | |
by Your Mother (Archbishop) on May 14, 2008 at 17:44 UTC | |
by shamu (Acolyte) on May 16, 2008 at 20:40 UTC | |
by Anonymous Monk on Feb 28, 2011 at 17:12 UTC |