[jdom-interest] Pb with mixed content (in b4)

Vincent Aumont vincent.aumont at vslab.com
Thu Jun 29 13:01:50 PDT 2000

If an element has mixed content *and* the last component is a string,
hasMixedContent always return 'false'. If the last component is
an element, it works as expected.
Consider the following example:

import java.io.*;
import org.jdom.*;
import org.jdom.input.*;

public class TestMixedContent {

  public static void main(String[] args)
    try {
      String mixedContent1 = "<root>a string<element>the
      String mixedContent2 = "<root>a string<element>the
element</element>another string</root>";
      SAXBuilder builder = new
      Document doc1 = builder.build(new
      if (doc1.getRootElement().hasMixedContent())
         System.out.println("doc 1 has mixed content");
      Document doc2 = builder.build(new
      if (doc2.getRootElement().hasMixedContent())
         System.out.println("doc 2 has mixed content");
    catch (Exception e) {e.printStackTrace();}


it produces:
doc 1 has mixed content

More information about the jdom-interest mailing list