Re: Bug (?) in XML::LibXML when creating XML docs with invalid characters
Francisco Obispo <[email protected]> Tue, 9 Apr 2013 09:49:47 -0700
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
Mhm, Looking at this, more closely now, it seems like appendText is an alias for appendTextNode, so that won't work, I tested the code in my computer and it doesn't show the problem: $ ./test.pl <?xml version="1.0" encoding="UTF-8"?> <elem></elem> what version are you using? I have 1.84 in mine. On Apr 9, 2013, at 9:02 AM, Francisco Obispo <[email protected]> wrote: > 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 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