How to wrap in String Content->xml element value with CDATA

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="color:blue hello,
<span style="color:blue in my program<span style="text-decoration:underline i get a string with xml content
from other system.<br/>
but the <span style="text-decoration:underline content is not valid xml (i cant chage the source system,therefore i need to fix this string ).<br/>
the <span style="text-decoration:underline second person element has <> charecrers inside the value.<br/>
this is causing <span style="text-decoration:underline xml to be <span style="text-decoration:underline
not valid.<br/>
so i want to wrap the value with <span style="color:#000000 CDATA
<span style="text-decoration:underline <span style="color:blue <span style="color:#000000 how can i manipulate string with regex or any other way to wrap the element value in a dynamic way ?
<span style="color:blue <span style="color:#000000 for example, string with xml content -
<span style="color:blue
<?xml version="1.0" encoding="utf-8" ?><br/>
<info><br/>
<person age="20 Ben</person><br/>
<person age="22 <span style="text-decoration:underline <David> </person><br/>
</info>
<span style="color:blue <br/>
CDATA solution:<br/>
<span><person><span><![CDATA[<David><span>]]><span></person>
<span style="color:blue <br/>

View the full article
 
Back
Top