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