Note that there are some explanatory texts on larger screens.

plurals
  1. POSAXParseException while parsing an xml
    primarykey
    data
    text
    <p>I am trying to parse an xml using DocumentBuilder's parse method which takes URI as an argument. For this I create a String object representing the URI and then call the parse method passing the String object as the argument.</p> <p>The parse method call works fine, returns a new DOM object. However, when I try to print the returned DOM object, it says: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. The code snippet for parsing the xml is as shown below:</p> <pre><code>String sURL="http://host:port/myapp/serv?arg=abc&amp;arg2=def"; DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); doc = dBuilder.parse(sURL); </code></pre> <p>When I manually try accessing the URL in a browser it works fine, i.e it returns the xml.</p> <p>The xml that the url returns is well formed. </p> <p>The parse method when called as shown above doesn't throw any exception, however the DOM object tells about org.xml.sax.SAXParseException</p> <p>Below is the stacktrace of the exception:</p> <blockquote> <p>org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(Unknown Source) at DocBuilderTest.getDocumentFromURL(DocBuilderTest.java:103) at DocBuilderTest.main(DocBuilderTest.java:54)</p> </blockquote> <p>Any help on this will be highly appreciated.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload