I have an XML document containing one or more consecutive
newlines in an
_attribute_ of one of the elements. The document is
well-formed XML according
to xmllint. When I try to parse this document using
XML::LibXML, and extract
the content of the attribute using findvalue(), the newlines
have been
transformed to spaces.
My application need to be able to distinguish spaces and
newlines in the
input documents (which are being generated by a third
party).
Is this at all possible?
Have tried this on two different systems, one running
versions 2.5.11/1.58,
the other running 2.6.26/1.61. The results are the same on
both systems.
Complete test case:
--- begin "test.xml" ---
<foo>
<bar baz="this
is
a
test"/>
</foo>
--- end "test.xml" ---
--- begin "test.pl" ---
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
my $parser = XML::LibXML->new();
my $dom = $parser->parse_file('test.xml');
my $baz = $dom->findvalue('/foo/bar/ baz');
print "baz:n", $baz;
--- end "test.pl" ---
$ ./test.pl > test.out
$ hexdump -C test.out
00000000 62 61 7a 3a 0a 74 68 69 73 20 69 73 20 20 20 20
|baz:.this is |
00000010 61 20 20 74 65 73 74
|a test|
00000017
--
Lars Haugseth
_______________________________________________
Perl-XML mailing list
Perl-XML listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
|