473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Bug in XML::DOM::toString()?

XML::DOM does not XML-escape text nodes' content on output. E.g., the
command

% perl -MXML::DOM -e 'print new
XML::DOM::Parser()->parse("<foo>&gt;</foo>")->toString()'

prints

<foo>></foo>

and not, as I would like and expect,

<foo>&gt;</foo>

Is there an easy way to simply XML-escape the content of all text
nodes, or something like that? (I can write a sub to do this myself, I
just figured there must be code for it already.)

It seems to do the right thing with attributes, BTW.

Aug 18 '05 #1
3 2401
Hmm, Google Groups seems to interpret that inline XML text differently
than I expected, too (looked fine in preview). Let me try again. In
case this second try doesn't come out properly either, what I'm trying
to show is that the greater-than sign, the only text content of the foo
element, is written in escaped form in the embedded XML text in the
perl script (i.e., ampersand g t semicolon), but when it's printed by
XML::DOM, out comes just a plain greater-than sign (so XML::DOM is
writing malformed XML). What I want is for the escaped form (ampersand
g t semicolon) to be written as the content of the foo node.

Second try at my original post:

XML::DOM does not XML-escape text nodes' content on output. E.g., the
command

% perl -MXML::DOM -e 'print new
XML::DOM::Parser()->parse("<foo>&amp;&gt;</foo>")->toString()'

prints

<foo>></foo>

and not, as I would like and expect,

<foo>&amp;&gt;</foo>

Is there an easy way to simply XML-escape the content of all text
nodes, or something like that? (I can write a sub to do this myself, I
just figured there must be code for it already.)

It seems to do the right thing with attributes, BTW.

Aug 19 '05 #2
vm*********@yahoo.com wrote:
% perl -MXML::DOM -e 'print new
XML::DOM::Parser()->parse("<foo>&amp;&gt;</foo>")->toString()'

prints

<foo>></foo>

and not, as I would like and expect,

<foo>&amp;&gt;</foo>


I get the expected output with XML::DOM 1.43. What version of XML::DOM
are you using?

Aug 20 '05 #3
Brian McCauley wrote:
vm*********@yahoo.com wrote:
% perl -MXML::DOM -e 'print new
XML::DOM::Parser()->parse("<foo>&amp;&gt;</foo>")->toString()'

prints

<foo>></foo>

and not, as I would like and expect,

<foo>&amp;&gt;</foo>


I get the expected output with XML::DOM 1.43. What version of XML::DOM
are you using?


I was using 1.27, which is the version included with Fedora Core 3. (I
assumed FC3 would be using the latest versions of everything, or anyway
closer than this.)

I just tried 1.44 (which happened to be what I got when I told CPAN to
"install XML::DOM") and that worked. Thanks!

Aug 25 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: user | last post by:
Hi How do i remove comments from a DOM object ? I tried searching the man pages XML::DOM, XML::DOM::Comment and XML::DOM::Document but could not find anything The code used to parse the...
2
by: Robert M. Gary | last post by:
I'm using JRE 1.5 on Solaris Japanese (Sparc). The JVM claims its default character set is EUC-JP I'm seeing two strange things when using Japanese character sets... 1) If I write a program that...
2
by: Rashida | last post by:
Hi all! I have written a function to fetch lebels from xml file for cross-language interoperability. Please refer function code below. I am invoking itfrom my asp page saying...
2
by: Daniel Bass | last post by:
given a snippet from an XML message .... <DATA name="John" value="23" /> <DATA name="Betty" value="71" /> <DATA name="Craig" value="" /> <DATA name="Lisa" value="42" /> .... I load this...
5
by: Kevin Burton | last post by:
I am sure this has been asked enough to warrant an FAQ but I could not find it. Does anyone have some code and maybe an XSLT stylesheet that would allow me to transform an XML string to a...
36
by: Wilfredo Sánchez Vega | last post by:
I'm having some issues around namespace handling with XML: >>> document = xml.dom.minidom.Document() >>> element = document.createElementNS("DAV:", "href") >>> document.appendChild(element)...
6
by: P James | last post by:
Hi, My project has been running for 4 years in ASP/IIS (originally on NT4, then on Win2003 as of 1 year ago), using the following code to parse the request object using the XML DOM: Set...
1
by: ar283 | last post by:
Hiya, I have a simple perl script that reads in an XML file (in utf8) using XML::DOM::Parser and spits it out again as follows: my $inFile = $ARGV; -f $inFile or die "$0: the input file...
1
jeffbroodwar
by: jeffbroodwar | last post by:
Hi, The code below prints : <Results><Row><customerName>jeff</customerName><address>None</address><telephone>None</telephone><birthday>2007-01-12 13:58:20.0</birthday></Row></Results> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.