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 7680591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:09:00+00:00 2026-05-31T18:09:00+00:00

I want to parse xml files that have elements like these: <element>&amp</element> <element>&amp;</element> But

  • 0

I want to parse xml files that have elements like these:

<element>&amp</element>
<element>&amp;</element>

But SAX Parser is giving me the following exception during parsing:

org.xml.sax.SAXParseException: The reference to entity "amp" must end with the ';' delimiter.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)

is there any known workaround for this?

The java code that throws the exception is this:

DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);
  • 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-31T18:09:01+00:00Added an answer on May 31, 2026 at 6:09 pm

    I’m unable to reproduce this with the XML you’ve shown (before your edit). Short but complete program:

    import java.io.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    
    public class Test {
        public static void main(String[] args) throws Exception {
            File file = new File("test.xml");
            DocumentBuilderFactory.newInstance()
                .newDocumentBuilder()
                    .parse(file);
        }
    }
    

    With a file of:

    <element>&amp;</element>
    

    … it runs with no error.

    When the file is just:

    <element>&amp</element>
    

    … it shows the same exception you reported.

    My conclusion is that it’s correct, and your file is broken. Look for every occurrence of &amp in the file, and find where it’s missing a semi-colon.

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

Sidebar

Related Questions

I have a simple but huge xml file like below. I want to parse
I want to sax-parse in nokogiri, but when it comes to parse xml element
I have an XML File with Elements that look like the following: <level> <name>Name
I have some .xml files that are encoded in UTF-8 . But whenever I
I want to parse a large XML file and I have two options: Perl
I parse a big xml document with Sax, I want to stop parsing the
HI, i need a XML parser. i want to know that which one is
I am (slowly) writing an XML parser for some site definition files that will
i have an xml file that looks something like this <library> <book name=ABC> <chapter
I have a javascript file that looks like this: if (x > 0 &&

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.