This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML Parsing problem

 
Chris Tjoumas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the javax.xml.parsers library to parse an XML file. I am doing this from an applet, so I have created a VBScript to generate the XML file. In my applet, I am trying to parse the XML file like this:
--------------------------------------------------------
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse( "http://devweb.nhlbi.nih.gov/LCEChris/Applet/Scripts/GetImages.asp?examNum=8381" );
traverse( doc );
} catch ( SAXException sxe ) {
sxe.printStackTrace();
} catch ( ParserConfigurationException pce ) {
pce.printStackTrace();
} catch ( IOException ioe ) {
ioe.printStackTrace();
} // end try-catch
--------------------------------------------------------
As you can see, the script name is GetImages.asp. I put that url with the query string param and the correct XML is generated. But, I am getting the following error:
org.xml.sax.SAXParseException: XML declaration may only begin entities.
I searched on that and there was a site that explained that this means that there could be whitespace preceding my xml declaration (http://community.voxeo.com/vxml/docs/vxml_1.3/loggermessages.htm). I viewed the source in IE and there was, in fact, two line breaks before my <?xml version="1.0"?> declaration.
Does anyone know what I can do to get around this problem? I don't see in my VBScript what would be causing the line breaks to be inserted. Or, is there another XML Parser for Java that would ignore these line breaks (if this is actually what is really causing the problem)?
Thanks!
Chris
 
Chris Tjoumas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah...I figured it out. I had an include directive above my xml declaration and used <enter> to put the xml declaration on the next line. Apparently the xml declaration needs to be right next to the include directive (on the same line).
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the XML forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic