문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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

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

See the javadoc for setExpandEmptyElements.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top