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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:32:20+00:00 2026-06-09T09:32:20+00:00

I am working on a simple XML parser in Java. I have been using

  • 0

I am working on a simple XML parser in Java. I have been using DocumentBuilderFactory successfully with many sources, but one of my new ones is a collection of individual nodes.

The file.xml looks like this:

<XML Version....>
<!DOCTYPE...>
<main_document_node>
.....others....
</main_document_node>
<XML Version....>
<!DOCTYPE...>
<main_document_node>
.....others....
 </main_document_node>

I had been using a command like this:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Document d = dbf.newDocumentBuilder().parse(/path/file.xml);

But that doesn’t seem to work with multiple parent nodes. Is there an easier way than making a temporary working file that I write a main_document_node to? That pseudo-code would be

new Writer temp.xml
new Reader file.xml
while not at the end of file.xml
    read/write first main_document_node to temp
    parse temp.xml

I think there should be a way to use the inputsource/stream option of the DocumentBuilderFactory, but I’m not sure how to go about doing that.

Thanks!

  • 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-06-09T09:32:22+00:00Added an answer on June 9, 2026 at 9:32 am

    You could skip the write to file step by creating an InputStream from the computet string fragment (for one node):

    new Reader file.xml
    while not at the end of file.xml {
        String node = read_first_main_document_node();
        InputStream is = new ByteArrayInputStream( node.getBytes( charset ) );
        parse(is); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started working on a simple XML pull-parser, and as I've just defuzzed
I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in
I've been using xml files to save data from my java program. I'm using
I have a simple XML without namespace. I am using XML::LibXML::Reader to parse the
Hi I have one xml file successfully parsed my before. now i am change
So basically what I have been doing is convert one xml file to a
I've been working on a simple weather app - and I'm using the Google
Good Day, I have a simple working routine in Perl that swaps two words:
I am working on a simple client-server project. Client is written in Java, it
I am using the PHP SimpleXML way of working with XML files on my

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.