Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with special characters " = etc...

Status
Not open for further replies.

devilhimself

Programmer
Nov 17, 2003
4
US
I have this perl script which extracts data from a file and converts it into an XML. But whenever it encounters a = " or any non-alphabet, non-digit character for that fact, IE throws up the following :
"Reference to undefined entity 'equals'. Error processing resource 'file:\\\..'" and the error pointer points to =

How do I overcome this problem with all characters. ?

Thanks,
V
 
Hi

The XML specification predefines five special pieces of code for characters that are normally recognized as part of the XML language itself. These are called "character entities" and they must be used if you want to include those characters as part of an element's content.

You should do some subtitutions in the XML File. Some add some code to the perl script:

#!/opt/nokianms/bin/perl

unless (open (XML, "<$xmlfile")) {
print "Cannot open input file: $xmlfile- conversion failed.\n";
exit(-1);
}

while ($file = <XML>) {

s/&/&amp;/;
s/</&lt;/;
s/>/&gt;/;
s/"/&quot;/;
s/’/&apos;/;

}

Also try writing it to the first line of the xml file if you have problems..

<?xml version="1.0" encoding="UTF-8"?>

Cheers!

 
XML only has five predefined entities, &lt, &gt, &apos, &quot, and &amp. These are used to escape one of these five special characters in the text of an XML document. e.g.
Code:
<ConditionalExpression>
if &amp.A &lt &amp.B
</ConditionalExpression>
If your are using any others they won't be recognised by a parser. But you don't need them, as these five are the only ones that cause parsing problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top