Specifying DOCTYPE for xml in Perl
I have written a perl script which scrapes a website and generates an HTML file. I pass on this file to a java servlet. On parsing the xml in the servlet i sometimes get a org.xml.sax.SAXParseException. I noticed that this exception is because the generated xml sometimes contains characters like nbsp, Iuml etc which cannot be parsed by the xml parser. Is there some way I can get over the problem?
Doing a bit of online search I found that declaring entities like
<!ENTITY nbsp CDATA "*" is one way to have a well formed xml. But how do I declare the entities in the perl file?
Any help would be appreciated.
I suggest you to convert the entities to numeric ones. I suggest using one of these modules:
or XML::Entities (the author of which is accidentally me).
Both are capable of converting named entities into numeric ones, which are inherently supported by XML.
I was able to get around the problem using the same method!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)