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

Hi All, I have a problem with the below code, the entity which appears inside attribute value gets position changed while using xml::dom parser. See the below example and suggest.

use XML::DOM; my $parser = new XML::DOM::Parser(ErrorContext => 1); $text='put any xml text here'; my $doc; if (! defined(eval {$doc = $parser->parse($text)})) { my $errs = $@; die("Did not parse: $errs\n"); } $doc->normalize(); print $doc->toString;

it's my input line
</ref><see-also seeref="Prothrow&ndash;Stith">
i am getting the below output. the entity which appears inside the attribute automatically placed before the element.
</ref>&ndash;<see-also seeref="ProthrowStith">

Replies are listed 'Best First'.
Re: XML::DOM entity error
by ikegami (Patriarch) on Jun 14, 2010 at 16:02 UTC
    &ndash; isn't an XML entity. XML only defines &amp;, &lt;, &gt;, &quot; and &apos;. Did you provide a definition for it? (This is usually done via a DOCTYPE directive.) Please provide an XML sample.
Re: XML::DOM entity error
by almut (Canon) on Jun 14, 2010 at 15:38 UTC

    Could you provide a complete (but small) XML sample that exhibits the problem?

    Your XML snippet does not parse as is, and when I complete it such that it does parse (including an entity declaration for &ndash; ), I cannot replicate the issue...