Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

XML::Parser undefined entity error

by ichimunki (Priest)
on Aug 18, 2001 at 17:56 UTC ( #105914=perlquestion: print w/ replies, xml ) Need Help??
ichimunki has asked for the wisdom of the Perl Monks concerning the following question:

I have XML like so:
<rec name="basic_header" type="template"> <title><pic path="logo"/>&nbsp;<link url="http://www.domain.com/"> +www.domain.com</link></title> <break type="line"/> </rec>

I have an XML::Parse constructor like so:
my $parser = XML::Parser->new( 'Handlers' => { Start => $xml_start, End => $xml_end, Char => $xml_char, Default => $xml_char, }, 'NoExpand' => 'TRUE', ); $parser->parse( $XML );
Where the handlers $xml_start, $xml_end, $xml_char are all anon sub refs-- the routines (for the most part) convert my XML to HTML for output. I've added the NoExpand option since this error, "undefined entity", started appearing. I've also tried point Unparsed and Entity handlers at $xml_char as well. Nothing helps... the error continues to appear. I suppose I could go to the trouble of creating an official DTD for my XML, but the list of entities is HUGE (since they will all be basically lifted from HTML)-- or are there a lot of entities I shouldn't have to define? Either way, how can I retain the entity in the text so that I can pass it along in my output?

Comment on XML::Parser undefined entity error
Select or Download Code
Re: XML::Parser undefined entity error
by mirod (Canon) on Aug 18, 2001 at 18:19 UTC

    What you can do is use a "fake" DTD:

    <?xml version="1.0"?> <!DOCTYPE rec SYSTEM "dummy.dtd" []> <rec>...

    This will get rid of the errors, and you will get the entity in the Default handler. Make sure you reset properly what you buffer in that handler and you should be all set.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://105914]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-07-10 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (214 votes), past polls