Re: LibXML: How do I serialize an attribute like this Attr="{"
to file
by Petr Pajas other posts by this author
Jan 19 2004 12:02PM messages near this date
view in the new Beta List Site
RE: LibXML: How do I serialize an attribute like this Attr="{" to file
|
Re: Yet another parser
<Derek_Chen@[...].tw> writes:
> My example is as below
>
> ------------------------------
> use XML::LibXML;
>
> my $parser = XML::LibXML->new();
> my $doc = $parser->parse_string(<<EOF);
> <A><AA Attr="B">xxx</AA></A>
> EOF
>
>
> @AA=$doc->getDocumentElement()->getElementsByTagName("AA");
> $AA[0]->setAttribute("Attr","{");
> $doc->toFile("a.xml");
> ------------------------------
> open a.xml you'll see <AA Attr="&#123;">
Ok, I didn't realize from the first mail you wrote that the attribut
is not a result of parsing xml but is rather created with
setAttribute. Your problem is thus not related to serialization but
to insertion. You cannot use character entities in setAttributes or
other DOM functions. Instead use the corresponding UTF-8 character You
may for example try setAttribute("Attr",chr(123)).
Petr
>
> -----Original Message-----
> From: Petr Pajas [mailto:pajas@[...].cz]
> Sent: Thursday, January 08, 2004 10:58 PM
> To: Derek Chen (RD-TW)
> Cc: perl-xml@[...].com
> Subject: Re: LibXML: How do I serialize an attribute like this Attr="{" to file
>
>
> <Derek_Chen@[...].tw> writes:
>
> > Hi,
>
> > I want my xml file having an element like this <abc
> > Attr="{"/>. But when I call $doc->toFile it becomes <abc
> > Attr="&#123;">. What should I do? Thanks.
> >
> > Derek
>
> Hm, I check with various setups, including the latest one using CVS
> versions of libxml2 and XML-LibXML and I cannot reproduce the problem.
> Please specify your libraries versions and send a functional
> reproducible example code demonstrating the behaviour you describe and
> XML file to test it with.
>
> -- Petr
>
> _______________________________________________
> Perl-XML mailing list
> Perl-XML@[...].com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Petr Pajas
|