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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:39:14+00:00 2026-05-17T06:39:14+00:00

I have to parse a XML structure in JAVA using the SAX parser. The

  • 0

I have to parse a XML structure in JAVA using the SAX parser.

The problem is that the structure is recursive with an unspecified count of recursions. This still is not such a big deal, the big deal is that I can’t take advantage of the XML namespace functionality and the tags are the same on every recursion level.

Here is an example of the structure.

<?xml version="1.0" encoding="UTF-8"?>
<RootTag>
    <!-- LOADS OF OTHER TAGS -->
    <Tags attribute="value">
        <Tag attribute="value">
            <SomeOtherTag></SomeOtherTag>
            <Tags attribute="value">
                <Tag attribute="value">
                    <SomeOtherTag></SomeOtherTag>
                    <Tags attribute="value">
                        <!-- MORE OF THE SAME STRUCTURE -->
                    </Tags>
                </Tag>
            </Tags>
        </Tag>
    </Tags>
    <!-- LOADS OF OTHER TAGS -->
</RootTag>

As you can see there is a recursion, better an undefined number of recursions. Now my problem is how to extract all data for every recursion and save it in a HashMap for example.

I could define a ContentHandler for the occurrence of Tags and have it extract the content in a HashMap and put it back in a master HashMap defined in the main content handler but I’m not sure hot to do this.

How do I extract and save the content of a recursive XML structure without using namespaces?

  • 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-17T06:39:15+00:00Added an answer on May 17, 2026 at 6:39 am

    Check out this set of Javaworld articles on using SAX. It demonstrates an easy way to parse a recursive XML structure using SAX. It creates a state machine showing for each element which elements it can contain. As your contentHandler traverses the xml it keeps a stack showing which element it’s currently on.

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

Sidebar

Related Questions

I have a problem with using the SAX parser to parse a XML file.
I have a simple XML structure like, that when parse with simplexml_load_string generates this:
I'm currently using SAX (Java) to parse a a handful of different XML documents,
I have an XML structure that looks like this: <root> <index> <item>item 1</item> <item>item
I currently have an XML Structure that looks something like this <Parent> <Info> <Info-Data></Info-Data>
I have an xml file that contains in products. File's structure this: <?xml version=1.0
I have to parse a 1Gb XML file with a structure such as below
I want to parse xml files that have elements like these: <element>&amp</element> <element>&amp;</element> But
please help me to parse xml from another xml... i have this xml named
I'm using jQuery to parse XML which is retrieved via ajax, however I have

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.