Promblem while parsing the XML

Hi,


I got the follwoing error while parsing the XML file.

[Fatal Error] :2:2325: The entity name must immediately follow the '&' in the entity reference.

 Exception: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.

My XML has a tag called <company_name> which contains & symbol like "ABC & Co".
How can i resolve it.

Thanx in advance.
hemanexpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
you have to replace & by &amp;
0
Geert BormansInformation ArchitectCommented:
an entity in XML is some sort of a shortcut or escape
you can define an entity eg "&MyComp;" as being "The full name of my Company"
and the parser will replace every instance of "&MyComp;" with "The full name of my Company"

For that, the parser expects an entity every time it hits a "&"

So if you want to use a plain "&" in your text, you need to replace it with a built in entity "&amp;"

There are several special characters in XML that have a prebuilt entity
&amp; = &
&lt; = <
&gt; = >
&apos; = '
&quot; = "

you can also escape special characters like this
&#233; = é (the unicode character 233)

or you can define your own entities
see example &MyComp;

cheers
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo EikelmanDirector, IT and Business DevelopmentCommented:
Or enclose the expression with CDATA:

<param name="expression"><![CDATA[ myURL.indexOf('&') > 0 ]]</param>

This might be a better solution as it will catch ANY characters that will cause this problem

such as &, >, <, etc..


Cheers,

Leo
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.