| Author |
SAX Parsing a one-line XML document
|
Peter Kleczka
Greenhorn
Joined: Feb 09, 2003
Posts: 18
|
|
Hi I'm trying to parse a file that has no carriage returns between the XML tags. In other words, the XML document is all on one line. The parser doesn't seem to pick up any of the content inside these tags unless I separate the tags with hard returns. Here is some of my code.... Is there something special I should be doing in the parser or content handler? The XML string I'll be getting is comming from another website, so I don't really have control of the XML document. TIA Pete (pkleczka@yahoo.com)
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
Originally posted by Peter Kleczka: I'm trying to parse a file that has no carriage returns between the XML tags. In other words, the XML document is all on one line. The parser doesn't seem to pick up any of the content inside these tags unless I separate the tags with hard returns.
This sounds to me like there's something wrong with the parser implementation. Which parser are you using?
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Peter Kleczka
Greenhorn
Joined: Feb 09, 2003
Posts: 18
|
|
|
I'm using Xerces but I'm not sure which version I'm using.
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
So is the problem that your characters(char[], int, int) method doesn't get called unless you add a '\n' between each <element>?
|
 |
Peter Kleczka
Greenhorn
Joined: Feb 09, 2003
Posts: 18
|
|
Sorry the real problem was an SAPIU (Stupid API User) error I was overcomplicating the callback methods in the ContentHandler and that made it appear that the parser was not doing things properly. All I need to do is keep track of the current tag, and if it is not an end tag print its contents. So my new code looks like the following... Thanks, Pete
|
 |
 |
|
|
subject: SAX Parsing a one-line XML document
|
|
|