how to serialize Java bean with empty element to xml with start and end tag instead of self-closing tag
See original GitHub issuewhen serialize to xml,I need <OrderId><OrderId/>
instead of <OrderId/>
,how to do it?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
[jackson-user] how to serialize Java bean with empty element ...
[jackson-user] how to serialize Java bean with empty element to xml with start and end tag instead of self-closing.
Read more >How to generate self-closing tag <tag/> for empty element in ...
When I marshal the entity to a XML string with: StringWriter sw = new StringWriter(); jaxbMarshaller.marshal(countryDataObject, sw); sw.toString ...
Read more >Start and end tag (empty) instead of self closing tags in xml
Hi. Is there any way to have empty tags i.e <tag_name></tag_name> instead of self closing tags i.e <tag_name/> while using tAdvancedOutputFileXml component.
Read more >Solving the XML Problem with Jackson - Stackify
Looking for a mature, flexible way of working with both JSON and XML for the same data? Read how the Jackson XML module...
Read more >Automatic replacement of closing tags - Oracle Communities
So, it should not illegal to have an empty element with a start and closing tag in XML. I would like to find...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you. Confirmed that the following does the trick.
outputFactory.setProperty(XMLOutputFactory2.P_AUTOMATIC_EMPTY_ELEMENTS, Boolean.FALSE);
.I set the property but it doesn’t work. code :
But if field is null ,the xml tag will be <FIELD_CHAR3/> ,if field is “” ,XmlMapper can generate normally
<FIELD_CHAR1></FIELD_CHAR1>. Do you have any idea can fix it?