Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

XML::Parser undefined entity error

by ichimunki (Priest)
on Aug 18, 2001 at 17:56 UTC ( [id://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?

Replies are listed 'Best First'.
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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (9)
As of 2024-04-23 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found