How to create a self-closing tag using JDOM

I could find any function in the Jdom api to create the closing xml tag itself, as <selfClosingTag />below.

For example, I need to create the following content:

<parentTag>
  <selfClosingTag />
  <firstChild>......    </firstChild>
  <secondChild>......    </secondChild>
</parentTag>

Can someone please tell me how to do this. Please tell me that I should not do this because this type of self-closing tag is required in the mathml document.

Thanks Chepukha

+3
source share
2 answers

Any item you create that you do not add child nodes to will be empty. An empty element can be represented as <element/>or <element></element>. Which one doesn't matter.

+4
source

, XMLOutputter, :

outputter.setFormat(outputter.getFormat().setExpandEmptyElements(false));

javadoc setExpandEmptyElements.

+2

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


All Articles