Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Just gettting started

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: adamc AT email.unc.edu
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Just gettting started
  • Date: Sat, 18 Feb 2006 16:13:09 -0500

Quoting David Ondzes <dondzes AT gmail.com>:

Hello All. I am relatively new to XML programming. While looking for
an easy to use/getting started XML package I found XOM. I am trying to
write an app that reads XML from a socket connection and I am getting

"[Fatal Error] :1:1: Content is not allowed in prolog."

That exception message refers specifically to having some text that isn't XML markup before the first element. Depending on *how* the text you're trying to parse is streamed to you, that well might be the cause of the problem you're seeing. For example, if you're getting it "raw" over HTTP, the response stream will contain the HTTP headers before the XML text.

My suggestion is to try reading the stream first without using XOM/Xerces to parse it, and dumping the results to a file or the console. This way, you'll be able to see what it is that Xerces (which is XOM's default XML parser) is trying to parse.

The first part of your document should be something like what's inside the triple quotes below:

"""<?xml version="1.0" encoding="utf-8"?>
<root>
"""

The first line (the XML declaration) is strictly speaking optional, but if it's not there the first text in the stream Xerces is trying to parse MUST be the root element or a DOCTYPE declaration (which looks like """<!DOCTYPE ...""")

Anything else at the beginning of the document and Xerces will (rightfully!) complain.

HTH

AC




Archive powered by MHonArc 2.6.24.

Top of Page