Is there a way to get JAVA to print blank CDATA inside Elements?

I know this inproper, but the company "on the other hand" for some reason forces us to change this code:

<POZ />

in

<POZ><!CDATA[[]]></POZ>

I found forced removal of CDATA elements , but this requires an additional XSL file, and I would like to avoid this.

I tried trivially

Element poz = new Element("POZ");
CDATA cdataContent = new CDATA("");
poz.addContent(cdataContent);

but he, of course, generates simple

<POZ />

not the extended version that I expect ...

Is there a way to get JAVA to generate these CDATA sections in empty elements?

+4
source share
2 answers

XML CDATA . , , .

DOM node , CDATA . , XML- CDATA, , .

, , , , .

+2

, XML, ,

<POZ>[[[[[[CDATA]]]]]]</POZ>

Java, sed .

0

Source: https://habr.com/ru/post/1525230/


All Articles