Question

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

For example, I need to create the following content:

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

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

Thanks, Chepukha

Was it helpful?

Solution

Any element you create, that you don't add any child nodes to, will be empty. An empty element can be represented as <element/> or <element></element>. Which one shouldn't really matter.

OTHER TIPS

It seems like modifying your XMLOutputter like this should do the trick:

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

See the javadoc for setExpandEmptyElements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top