Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9038

Re: org.xml.sax.SAXParseException: Premature end of file

From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: org.xml.sax.SAXParseException: Premature end of file
Date 2011-10-20 10:04 -0700
Organization A noiseless patient Spider
Message-ID <j7pka5$bqr$1@dont-email.me> (permalink)
References <22aef44f-90f0-4fe4-a20e-64f336e4c1b3@g25g2000yqh.googlegroups.com>

Show all headers | View raw


On 10/20/2011 8:41 AM, laredotornado wrote:

> I'm using Java 6.  I'm trying to parse some well-formed (or at least
> that's what I thought) XML but am getting a "SAXParseException:


It worked for me.


> Premature end of file" exception (below).  The code I'm using is


No, this is not the code.  There's a syntax error: inputStream and 
xmlInputStream are being confused here, xmlInputStream is not declared.


>
> 		xml = xml.trim();
> 		final InputStream inputStream = new
> ByteArrayInputStream(xml.getBytes());
> 		final DocumentBuilderFactory dbf =
> DocumentBuilderFactory.newInstance();
> 		final DocumentBuilder db = dbf.newDocumentBuilder();
> 		final Document doc = db.parse(xmlInputStream);
>
> The block I'm trying to parse is below.  Can anyone see how it is mal-
> formed?  Barring that, do you know a better way of parsing the string?


Yes, there's a syntax error in the XML.  Construct a proper SSCCE to see it.


Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

org.xml.sax.SAXParseException: Premature end of file laredotornado <laredotornado@zipmail.com> - 2011-10-20 08:41 -0700
  Re: org.xml.sax.SAXParseException: Premature end of file markspace <-@.> - 2011-10-20 10:04 -0700
    Re: org.xml.sax.SAXParseException: Premature end of file laredotornado <laredotornado@zipmail.com> - 2011-10-20 10:59 -0700
      Re: org.xml.sax.SAXParseException: Premature end of file Lew <lewbloch@gmail.com> - 2011-10-20 14:06 -0700
  Re: org.xml.sax.SAXParseException: Premature end of file Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-10-20 20:15 +0200

csiph-web