Reputation: 623
I have problem when using JOOX for transforming XMLs. I am doing some changes to element matching the fieldTag
I have a code as following:
Match xml = $(new StringReader(content.toString()));
Match find = xml.find(fieldTag);
Iterator<Element> iterator = find.iterator();
while(iterator.hasNext()){
Element next = iterator.next();
String text = $(next).text();
if(text.length() == 0) continue;
next.setNodeValue("....");
}
return xml.toString();
However , for example an XML like this is input:
<Body>
<A>ABC</A>
<B></B>
</Body>
this is what i get as result:
<Body>
<A>transformed</A>
<B/>
</Body>
You can notice that Element B is a self closed XML tag. Does anyone know that how do I make it to be <B></B
??
Upvotes: 0
Views: 108
Reputation: 163498
Why does it matter? Anyone who reads the resulting document with an XML parser won't notice the difference, and anyone who reads it with something that isn't an XML parser needs to be re-educated. Most XML serializers don't give you any control over such details, any more than they allow you to choose whether to have single quotes or double quotes around your attribute values.
Upvotes: 1