Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java adding cdata to xml string

Tags:

java

xml

cdata

I need to add CDATA to xml string for sign it with certificate.

String looks like:

<SignedContent>someparametres</SignedContent>

Result must be like:

<![CDATA[<SignedContent>someparametres</SignedContent>]]>

How can i do this? Pls help

P.S. Xml string has only one row (removed all tabs, all spaces, BOM)

like image 791
NovaCenturion Avatar asked Dec 12 '22 05:12

NovaCenturion


1 Answers

It sounds like you just want:

Node cdata = doc.createCDATASection(text);
parentElement.appendChild(cdata);
like image 115
Jon Skeet Avatar answered Dec 21 '22 04:12

Jon Skeet