Re: Bug (?) in XML::LibXML when creating XML docs with invalid characters
Francisco Obispo <[email protected]> Tue, 9 Apr 2013 09:02:37 -0700
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
You should probably use $element->appendTextNode($c); On Apr 9, 2013, at 4:11 AM, aitor <[email protected]> wrote: > Hi, > > the following perl snippet creates an invalid XML using LibXML > functions, which I though was not possible. The idea is to attach a > malformed character via "appendText". I would say that the function > should fail when feeding invalid characters ? > > test.pl > ******* > > #!/usr/bin/perl > > use XML::LibXML; > > my $c = pack("W", 07); # the invalid character > > my $odoc = XML::LibXML::Document->new('1.0',"UTF-8"); > my $elem = $odoc->createElement("elem"); > $odoc->setDocumentElement($elem); > $elem->appendText($c); > print $odoc->toString(1)."\n"; > > ****** > % perl test.pl > test.xml > % xmllint --noout test.xml > test.xml:2: parser error : PCDATA invalid Char value 7 > <elem>lem> > ^ > > Any ideas ? > > best, > aitor > _______________________________________________ > Perl-XML mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Francisco Obispo Director of Applications and Services - ISC email: [email protected] Phone: +1 650 423 1374 || INOC-DBA *3557* NOC PGP KeyID = B38DB1BE _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs