Search code examples
javaxmlxml-parsingjdomjdom-2

How to detect an empty tag in xml document using jdom


I'm using JDOM to parse an xml document that could be like this:

<person>
  <name id="blah"> xyz </name>
  <friends />
</person>

I'm trying to find out what the correct way to detect an empty tag such as <friends /> or <friends></friends>

would be.


Solution

  • Get the Element for the <friends> tag and for an empty element the getChildren() method should return an empty list.