| To: | users@xxxxxxxxxx |
|---|---|
| Subject: | parsing using jdom |
| From: | "Jason Kretzer/STAR BASE Consulting Inc." <JKretzer@xxxxxxxxxxxxxxx> |
| Date: | Wed, 21 Apr 2004 15:45:58 -0400 |
| Delivered-to: | mailing list users@cinjug.org |
| Mailing-list: | contact users-help@cinjug.org; run by ezmlm |
|
I am using jdom to parse a stream from a url -- the one mentioned in my previous posts. When I try to parse it, I get the following error. --------------------------------------- org.jdom.input.JDOMParseException: Error on line 13 of document https://someWebSite.com/giveXML.jsp?someparam=paramOne: XML declaration may only begin entities. --------------------------------------- I am using the following code to parse it. --------------------------------------- SAXBuilder builder = new SAXBuilder(); builder.setValidation(true); builder.setIgnoringElementContentWhitespace(true); Document doc = builder.build(url); --------------------------------------- where url is the url from before. After getting this error, printed out the xml document using the following code. --------------------------------------- InputStreamReader isr = new InputStreamReader(url.openStream()); BufferedReader br = new BufferedReader(isr); String line = br.readLine(); while(line != null) { System.out.println(line); line = br.readLine(); } br.close(); --------------------------------------- I redirected the output to a file and opened it with IE and it opened fine. When I tried to parse the file using the above code though I received this error. --------------------------------------- org.jdom.input.JDOMParseException: Error on line 1 of document file:/output.xml: Document root element is missing. --------------------------------------- I have posted a the first few lines of the file, I printed out. Only some of the element names have been changed. I also cut off the first 12 lines as they were blank for some reason. Anyone know what I can do to fix this? Thanks, -Jason <?xml version="1.0" ?> <!DOCTYPE ROOT_ELEMENT [ <!ELEMENT ROOT_ELEMENT (MESSAGE_ID, ELEMENT_ONE*)> <!ELEMENT MESSAGE_ID (#PCDATA)> <!ELEMENT ELEMENT_ONE (TEST_ROOT, TEST_ELEMENT+)> <!ELEMENT TEST_ELEMENT (TEST_CODE, TEST_VERSION, TEST_ACCESS, TEST_DESCRIPTION?,TEST_PREDECESSOR_CODE?)> <!ELEMENT TEST_CODE (#PCDATA)> <!ELEMENT TEST_ROOT (#PCDATA)> <!ELEMENT TEST_VERSION (#PCDATA)> <!ELEMENT TEST_ACCESS (#PCDATA)> <!ELEMENT TEST_DESCRIPTION (#PCDATA)> <!ELEMENT TEST_PREDECESSOR_CODE (#PCDATA)> ]> <ROOT_ELEMENT> <MESSAGE_ID></MESSAGE_ID> <ELEMENT_ONE> <TEST_ROOT>some text</TEST_ROOT> <TEST_ELEMENT> <TEST_CODE>NE2-C</TEST_CODE> <TEST_VERSION>Comp</TEST_VERSION> <TEST_ACCESS>N</TEST_ACCESS> <TEST_PREDECESSOR_CODE>pred_code</TEST_PREDECESSOR_CODE> </TEST_ELEMENT> <TEST_ELEMENT> <TEST_CODE>NE2</TEST_CODE> <TEST_VERSION>Secure</TEST_VERSION> <TEST_ACCESS>Y</TEST_ACCESS> <TEST_PREDECESSOR_CODE>pred_code other</TEST_PREDECESSOR_CODE> </TEST_ELEMENT> </ELEMENT_ONE> .......... |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [cinjug-users] https login page, Edward Sumerfield |
|---|---|
| Next by Date: | RE: [cinjug-users] parsing using jdom, Robert Casto |
| Previous by Thread: | RE: [cinjug-users] https login page, Griffiths Glen D Contr MSG/SLR |
| Next by Thread: | RE: [cinjug-users] parsing using jdom, Robert Casto |
| Indexes: | [Date] [Thread] [Top] [All Lists] |