Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.rometools.rome.io.XmlReader can't read compressed data from java.net.URLConnection #461

Closed
patexoid opened this issue Nov 30, 2020 · 1 comment

Comments

@patexoid
Copy link

SyndFeed feed = new SyndFeedInput().build(new XmlReader(connection));
Fails if connection.getHeaderField("Content-Encoding") is 'gzip'

Exception

com.rometools.rome.io.ParsingFeedException: Invalid XML: Error on line 1: Content is not allowed in prolog.
       at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:236)
       at com.rometools.rome.io.SyndFeedInput.build(SyndFeedInput.java:150)
.....
 Caused by: org.jdom2.input.JDOMParseException: Error on line 1: Content is not allowed in prolog.
       at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:232)
       at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:303)
       at org.jdom2.input.SAXBuilder.build(SAXBuilder.java:1196)
       at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:233)
       ... 9 more
 Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
       at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
       at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178)
       at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
       at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
       at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1471)
       at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:978)
       at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
       at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
       at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:541)
       at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
       at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
       at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
       at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
       at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)
       at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:217)
       ... 12 more

@patexoid patexoid mentioned this issue Dec 1, 2020
@PatrickGotthard
Copy link
Member

Hi @patexoid,

the XmlReader works only for simple cases. Please download the feed with a dedicated HTTP library and then use Rome to parse the content. Here are some examples: #276

Regards,
Patrick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants