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

  • SEARCH
  • Home
  • 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 7963683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:39:51+00:00 2026-06-04T05:39:51+00:00

I have been tasked with splitting an XML file into two parts for ease

  • 0

I have been tasked with splitting an XML file into two parts for ease of editing.

But all the existing codebase is designed to treat it as a single file.

As a middle ground (due to a paucity of time) I decided to split the files, but simply concatenate the split files by using the following code

    var xmlDoc;
    xmlhttp.open("GET","distributome-relations.xml",false);
    xmlhttp.send();
    xmlDoc = xmlhttp.responseXML;
    xmlhttp=createAjaxRequest();
    xmlhttp.open("GET","distributome-references.xml",false);
    xmlhttp.send();
    xmlDoc = xmlDoc+xmlhttp.responseXML;
            try{
        DistributomeXML_Objects=xmlDoc.documentElement.childNodes;
    }catch(error){
        DistributomeXML_Objects=xmlDoc.childNodes;
    }

Which doesn’t seem to work while the original code

xmlhttp.open("GET","Distributome.xml",false);
    xmlhttp.send();
    if (!xmlhttp.responseXML.documentElement && xmlhttp.responseStream)
        xmlhttp.responseXML.load(xmlhttp.responseStream);
    xmlDoc = xmlhttp.responseXML;
    try{
        DistributomeXML_Objects=xmlDoc.documentElement.childNodes;
    }catch(error){
        DistributomeXML_Objects=xmlDoc.childNodes;
    }

Works perfectly fine.

I’m not sure how to proceed with this.

I have simply split the file

http://www.distributome.avinashc.com/avinash/Distributome.xml into

http://www.distributome.avinashc.com/avinash/distributome-relations.xml and
http://www.distributome.avinashc.com/avinash/distributome-references.xml

The last two files will appear improperly formatted because only a simple concatenation of the two files is expected to be a valid XML document.

I suspect that this is due to the use of the responseXML method and that I should use an alternate method.

Is there a better way to do this. I would welcome any suggestions, and of course – answers to my original question.

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-04T05:39:53+00:00Added an answer on June 4, 2026 at 5:39 am

    It would help if you explained what doesn't seem to work translates to but from a quick look at your code I can tell that you are trying to concatenate two DOM Document objects using +. This line:

    xmlDoc = xmlDoc + xmlhttp.responseXML;
    

    The responseXML property of the XHR doesn’t return a string like you seem to expect (btw, concatenating two XML files like that would very likely result into a not well formed XML anyway). The second example treats it properly for what it is – the DOM Document object.

    You can read more about responseXML over at MDN. Pay attention to the note about the Content-Type and how you might need to use the overrideMimeType() on your XHR to make it believe it received an XML from the server if the server didn’t set the header properly.

    To do your concatenation in the XML-aware fashion you would need to grab the root node from the second document (document.documentElement), import it into the first document using the importNode() and then append it as a child node where you want it to be using appendChild()

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

Sidebar

Related Questions

I have been tasked with finding an open source DOM XML parser. The parser
I have been tasked with converting several php classes into java classes, which is
I've inherited a rather large and somewhat messy codebase, and have been tasked with
I have been tasked to replace the hardware an existing Apache/Tomcat/MySQL application is running.
I have been tasked with migrating an existing mature ASP.NET 2.0 web site to
I've been tasked with programmatically splitting up an HTML master template into subtemplates, performing
I have been tasked to add an on-line help file to a windows application.
I have been tasked with making an existing Java program available via a web
I have been tasked to write a module for importing data into a client's
So I have this Access Database Project file that I have been tasked to

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.