Z
zhengwt
I used JDOM.jar to process xml-based document.
Recently, I meet such a problem that I can not solve.
First, I use the following code generate xml text:
Element root = new Element("Root");
Document doc = new Document(root);
... // add some elements appended to root
XMLOutputter out = new XMLOutputter();
out.setFormat(Format.getPrettyFormat());
String xml = out.outputString(doc);
The content in "xml" is something like:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
...
</Root>
After then, I use the following code to build a DOM based on "xml":
SAXBuilder builder = new SAXBuilder(false);
builder.setIgnoringElementContentWhitespace(true);
Document doc = builder.build(xml);
The problem comes out, the exception message says:
java.net.MalformedURLException: no protocol: <?xml version="1.0"
encoding="UTF-8"?>
<Root>
...
</Root>
How to solve it? Thanks in advance!
Recently, I meet such a problem that I can not solve.
First, I use the following code generate xml text:
Element root = new Element("Root");
Document doc = new Document(root);
... // add some elements appended to root
XMLOutputter out = new XMLOutputter();
out.setFormat(Format.getPrettyFormat());
String xml = out.outputString(doc);
The content in "xml" is something like:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
...
</Root>
After then, I use the following code to build a DOM based on "xml":
SAXBuilder builder = new SAXBuilder(false);
builder.setIgnoringElementContentWhitespace(true);
Document doc = builder.build(xml);
The problem comes out, the exception message says:
java.net.MalformedURLException: no protocol: <?xml version="1.0"
encoding="UTF-8"?>
<Root>
...
</Root>
How to solve it? Thanks in advance!