tom john wrote:
I need to create xml document from string. if the text
contains special characters like '&' it throws error.
is there any solution for this... may be some special feature that i can set for the
parser.
__________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tom,
A little method like this can maybe fix your problem. It processes a raw string into an XML-compatible one:
String xmlString(String val) { if (val==null) return val; StringBuffer buf = new StringBuffer(); for (int i=0;i<val.length();i++) { char ch = val.charAt(i); if (ch=='&') buf.append("&"); else if (ch=='<') buf.append("<"); else if (ch=='>') buf.append(">"); else if (ch=='\'') buf.append("'"); else if (ch=='"') buf.append("""); else buf.append(ch); } val=buf.toString(); return val; }
It will turn something like
"Rock & roll"
into
"Rock & roll"
Hope this helps.
Bob Jamison LinCom Corp
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
