• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Parsing problem

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the XML forum.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic