Urgent!!! Check for Special chars <, >, &, / etc in XML doc stored in a String?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Prashanth_n
Posted On:   Friday, August 3, 2001 07:41 AM

Hi,
I need to check for special chars in the data within an XML document that I have stored as a String variable in a Java program. The likely characters that could be in the data that could cause problem with XML syntax may be chars like ' <', '>', '/', '&' etc... These characters being part of XML syntax, make it difficult to be searched in a string that contains data within the XML document having XML tags/Syntax. Though I can always transform the String into an object tree & traverse, it would be too complex a coding for a simple requirement like mine & I donot have that much time... Somebody please reply at the earliest.

Thanks,
Prashanth

Re: Urgent!!! Check for Special chars &lt;, &gt;, &, / etc in XML doc stored in a String?

Posted By:   Christopher_Schultz  
Posted On:   Friday, August 3, 2001 11:35 AM

You're pretty much going to have to loop through your string and replace or escape those characters yourself. I'm sure you can find source code to do it somewhere, but it's probably a 5-line method to write, anyway.

-chris
About | Sitemap | Contact