tags:

views:

175

answers:

3

Hi,

I am reading the input Excel file and in that i have 1 fields for the address.In that field the special character is coming which is (&).While i am going to parse this character (&) and trying to write it to the XML file at that time the character converts into the (&amp).

I want to remove the translated character (&amp) from the XML file and wants that it must remain as it was read from the Excel file and writtern as the (&) in the XML file. WWW.GEVERS& converted to WWW.GEVERS&amp if any body has any solution or any other code snippet,which would be appreciated.

Thanks,

Mishal Shah

+2  A: 

If your data contains an ampersand -- which apparently it does -- then that ampersand has to be escaped as & if you put it in a text node in your XML document.

So it sounds like your XML software is behaving correctly. Why do you think you have to do anything about this? I don't think you do.

Paul Clapham
Jim Ferrans
A: 

Since it will not be a valid xml file anymore, you should handle it as raw text and do a raw replace of & -> &

By the way, why don't you want to keep it valid xml ?

Zeograd
+1  A: 

@Mishal, see Paul's answer. If you replace the & with a &, you no longer have a "well-formed" XML document. You would actually be introducing a syntax error.

So you just need to read or view your XML document with a program that knows how to render XML, such as Internet Explorer (just make sure your file suffix is .xml).

Jim Ferrans