[jdom-interest] Problem with mixed content

Jason Hunter jhunter at collab.net
Tue Sep 12 00:03:14 PDT 2000

> I dowloaded JDom sources from 09.08.2000.
> I have simple xml like this:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <test>
>   <element>
>     text
>   </element>
> </test>
> and when I do
>         Document doc = builder.build(new File(filename));
>         Element root = doc.getRootElement();
>         System.out.println("hasMixedContent="+root.hasMixedContent());
> I receive true, but there no mixed content in this xml.

Sure there is.  There's lots of whitespace.  Yes, I agree that's kinda
stupid but that's XML for ya!  Without validation you can't tell if the
whitespace is ignorable or not.  Also notice that the getText() value
for the element is "\n    text\n  ".  Use getTextTrim() if you want just


More information about the jdom-interest mailing list