Reputation: 23
I am writing a parser in Java where I am writing a string in XML dom.
my problem is a String "test"
should come as "test"
but it is coming as "test"
Here is my code
Element elment1 = new Element("string");
elment1.addContent("test");
i get it in the xml like this
<string>"test"</string>
but i want to get it like this
<string>"anytext"</string>
i use this to creat the xml file
Document doc = new Document(root);
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.output(doc,new FileWriter("path"))
Upvotes: 0
Views: 150
Reputation: 163322
If you use a standard off-the-shelf serializer, it will not escape a double-quotation-mark "
appearing in a text node as an entity reference; it will only escape things that actually need to be escaped.
I can't imagine why you would want this unnecessary escaping, but it you do, you will need to do the serialization yourself "by hand".
Upvotes: 0