kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

Revered Monks,
I am using XML::DOM parser to parse the XML file, and when the input file contains characters like &,&lt,>,&quote,'the ouput to a file is just & instead of the full &

Any solution to this???I have the below link which didnt tells me much
http://perl-xml.sourceforge.net/faq/

Please advice

-Prasanna.K

Replies are listed 'Best First'.
Re: issue using use XML::DOM parser
by pc88mxer (Vicar) on Jun 24, 2008 at 22:58 UTC
    I have a feeling that XML::DOM is doing the right thing. The string & is an encoding of the character &.

    If you want to print encoded output, use the encode_entities() routine from HTML::Entities or a module that writes XML like XML::Writer.

      HTML::Entities encode_entities is not appropriate for XML, but encode_entities_numeric is.
Re: issue using use XML::DOM parser
by ikegami (Patriarch) on Jun 25, 2008 at 00:14 UTC

    You're very light on the details. How are you outputting to a file? If you're generating XML from text, you'll need to encode a few characters including &.

    Functions that return XML should return "&"
    Functions that return text should return "&"