Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Problem parsing HTML file into Document

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <wolfgang.hoschek AT mac.com>
  • To: Nick Day <the_doctor_nick AT hotmail.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Problem parsing HTML file into Document
  • Date: Sat, 10 Dec 2005 17:55:00 -0800

HTML is not wellformed XML, so you need to preprocess it with something like TagSoup.
Tagsoup makes HTML appear as if it were XML. See http:// mercury.ccil.org/~cowan/XML/tagsoup/

Wolfgang.

On Dec 10, 2005, at 3:09 PM, Nick Day wrote:

Hi,

I've been having a bit of trouble parsing a HTML file (attached) into a document and keep getting the error below. Do I need to preprocess the file into a different encoding before attempting the creation of the Document object or am I way off?

thanks,
Nick

nu.xom.ParsingException: Invalid byte 1 of 1-byte UTF-8 sequence. in file:/f:/test.txt
at nu.xom.Builder.build(Builder.java:1157)
at nu.xom.Builder.build(Builder.java:614)
at nu.xom.Builder.build(Builder.java:990)
at uk.ac.cam.ch.wwmm.scuflworkers.java.StripElementsFromXMLTest.main (StripElementsFromXMLTest.java:23)
Caused by: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.scanLiteral(Unknown Source)
at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanAttribute (Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement (Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl $FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument (Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at nu.xom.Builder.build(Builder.java:1127)
... 3 more
Exception in thread "main" java.lang.NullPointerException
at uk.ac.cam.ch.wwmm.scuflworkers.java.StripElementsFromXml.strip (StripElementsFromXml.java:22)
at uk.ac.cam.ch.wwmm.scuflworkers.java.StripElementsFromXMLTest.main (StripElementsFromXMLTest.java:34)


<test.txt>
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest






Archive powered by MHonArc 2.6.24.

Top of Page