File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Document:  No DOCTYPE declaration, Root is [Element: <nodename/>] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Document:  No DOCTYPE declaration, Root is [Element: <nodename/>]" Watch "Document:  No DOCTYPE declaration, Root is [Element: <nodename/>]" New topic

Document: No DOCTYPE declaration, Root is [Element: <nodename/>]

Raguram Ramasubbu

Joined: Oct 27, 2007
Posts: 1

It would be better if somebody helps me to resolve an issue I am facing while converting XML string into JDom Document object.

The XML string looks as

<?xml version="1.0" encoding="UTF-8"?>
<link pageID="" modal="true">
<param name="id">10000</param>
<displayText>is 30 years old.</displayText>

and java code looks as

org.jdom.Document document = null;
SAXBuilder builder = new SAXBuilder();

try {
document = StringReader(xmlString));
} catch (JDOMException e) {
} catch (IOException e) {
} catch (Exception e) {
return document;

in runtime I get error like [Document: No DOCTYPE declaration, Root is [Element: <items/>]]

Can somebody helps me what is the problem with the XML and how can I resolve this issue?

Thanks in advance.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19875

What makes you think that's an error? If an exception were really being thrown, you wouldn't know what it was because your catch-blocks are all empty. (Don't do that, you need to know what the exception was). So where is that output coming from in your code?

(And when you post code, or XML, please post it inside the "code" tags which you can get by clicking the "Code" button above the box you're about to post in.)
David Newton

Joined: Sep 29, 2008
Posts: 12617

Well, there's no doctype; maybe you need one?
I agree. Here's the link:
subject: Document: No DOCTYPE declaration, Root is [Element: <nodename/>]
It's not a secret anymore!