Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Transforming String with < > to XML

843834Apr 29 2009 — edited Apr 30 2009
Hi,

I have an application which sends XML message similar to:
<ParentElement>
<Data><![CDATA[&lt ;?xml version="1.0" encoding="UTF-8"?&gt ;
&lt ;Element1&gt ;
&lt ;Element2&gt ;mydata&lt ;/Element2&gt ;
&lt ;/Element1&gt ;]]></Data>
</ParentElement>
I require to fetch the content from the Data element and convert it to XML. I do this by fetching the content in Data element as String and replacing &lt ; &gt ; and &quot ; using replaceAll method in java.lang.String and then use DOM API to convert String to XML. Is there a better way of doing this instead of using the replaceAll method and transforming the xml in String to DOM? Please note for display purposes I have a space between lt and semi-colon in the XML
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2009
Added on Apr 29 2009
4 comments
396 views