Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7646017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:05:53+00:00 2026-05-31T10:05:53+00:00

SAXParseException is occuring while iam trying to parse an xml unsing dom parser here

  • 0

SAXParseException is occuring while iam trying to parse an xml unsing dom parser

here is the code using

public static getAlertsFromXML(InputStream strAlerts) {
                              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                InputSource is = new InputSource(strAlerts);        
                is.setEncoding("UTF-8"); 
                Document doc =db.parse(is); 
}

org.xml.sax.SAXParseException: Premature end of file is showing while running the code.

xml is

<?xml version="1.0" encoding="UTF-8"?>
-<seloger result="1" url="http://wshp.seloger.com/getalerts.xml?printerid=3Gs8rsDHrclGqD1Hrr1p08dr2" version="1.0">
<!-- ID3x v4.60 (387) - X29 - 00.056.330 - base - 14/03/2012 09:56:09 - getalerts.xml -->
 -<listalerts> -<alert> <alertId>10049086</alertId> <description>locations d'appartements ou de maisons situées dans le 75, ayant une surface supérieure à 567 m², pour un loyer inférieur à 100 000 000 €/mois, triées par prix.</description> <creationDate>2011-10-13T11:16:00</creationDate> <queryString>cp=75&idqfix=1&idtt=1&idtypebien=1,2&px_loyerbtw=NAN%2f100000000&surfacebtw=567%2fNAN&tri=</queryString> </alert> -<alert> <alertId>9348308</alertId> <description>ventes situées à Caen (Calvados), à Cambes (Lot-et-Garonne), à Paris 1er, à Paris 2ème, à Paris 3ème, à Paris 4ème, à Paris 5ème, à Paris 6ème, à Paris 7ème, à Paris 8ème, à Paris 9ème, à Paris 10ème, à Paris 11ème, à Paris 12ème, à Paris 13ème, à Paris 14ème, à Paris 15ème, à Paris 16ème, à Paris 17ème, à Paris 18ème, à Paris 19ème ou à Paris 20ème, ayant une surface inférieure à 1 000 m², triées par prix.</description> <creationDate>2011-06-27T07:42:00</creationDate> <queryString>ci=140118,470047,750101,750102,750103,750104,750105,750106,750107,750108,750109,750110,750111,750112,750113,750114,750115,750116,750117,750118,750119,750120&fakeci=750056&idqfix=1&idtt=2&idtypebien=all&nb_chambres=all&nb_pieces=all&pxbtw=NaN%2fNaN&surfacebtw=NaN%2f1000&tri=d_dt_crea</queryString> </alert> -<alert> <alertId>9337215</alertId> <description>ventes situées à Paris 1er, à Paris 2ème, à Paris 3ème, à Paris 4ème, à Paris 5ème, à Paris 6ème, à Paris 7ème, à Paris 8ème, à Paris 9ème, à Paris 10ème, à Paris 11ème, à Paris 12ème, à Paris 13ème, à Paris 14ème, à Paris 15ème, à Paris 16ème, à Paris 17ème, à Paris 18ème, à Paris 19ème ou à Paris 20ème, ayant une surface inférieure à 1 000 m², pour un prix compris entre 50 et 1 000 €, triées par prix.</description> <creationDate>2011-06-24T13:40:00</creationDate> <queryString>ci=750101,750102,750103,750104,750105,750106,750107,750108,750109,750110,750111,750112,750113,750114,750115,750116,750117,750118,750119,750120&fakeci=750056&idqfix=1&idtt=2&idtypebien=all&nb_chambres=all&nb_pieces=all&pxbtw=50%2f1000&surfacebtw=NaN%2f1000&tri=d_dt_crea</queryString> </alert> </listalerts> </seloger>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:05:55+00:00Added an answer on May 31, 2026 at 10:05 am

    The ampersand is a reserved character in XML; <marker>Bob & Mary Johnson</marker> is not valid XML. You must escape it as & or wrap it in order to hide it from your XML parser, e.g. <marker><![CDATA[Bob & Mary Johnson]]></marker>.

    For more information refer List of XML and HTML character entity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use DOM Parser in Java to parse a small XML
I'm trying to parse a file from the web on Android using the DOM
I'm getting this error while trying to de-serialize my object : [org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The
Im trying to parse the XML returned by the Google Geo code API ,but
Parsing an XML file using the Java DOM parser results in: [Fatal Error] os__flag_8c.xml:103:135:
We're parsing an XML document using JAXB and get this error: [org.xml.sax.SAXParseException: Invalid byte
I have an xml file I'm trying to parse and it is UTF-16 encoded.
I have the following code: import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; DocumentBuilderFactory factory =
I'm trying to validade a XML against a W3C XML Schema. The following code
I am using the SAX parser in java to read some XML. The XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.