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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:04:21+00:00 2026-06-11T00:04:21+00:00

I have the following, which loads XML from a web site and parses it:

  • 0

I have the following, which loads XML from a web site and parses it:

function load() {
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = parse;
  xhttp.open('GET', 'http://...XML.xml', false);
  xhttp.send();
}

function parse() {
  xmlDoc = xhttp.responseXML.documentElement.childNodes;
  for (var i = 0; i < xmlDoc.length; i++) {
    nodeName = xmlDoc[i].nodeName;
    ...
}

After I loading this, I store it in localStorage and I can retrieve it as a string. I need to be able to convert it back to a xml document just like:

xmlDoc = xhttp.responseXML.documentElement.childNodes;

does, so i can parse it. I have been looking for awhile now and can not figure it out.

Thanks in advance.

  • 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-11T00:04:23+00:00Added an answer on June 11, 2026 at 12:04 am

    Based on the answer here XML parsing of a variable string in JavaScript Credit to @tim-down

    You need to create an XML parser. Then pass the string into your parse instance. Then you should be able to query it as per before.

    var parseXml;
    
    if (typeof window.DOMParser != "undefined") {
        parseXml = function(xmlStr) {
            return ( new window.DOMParser() ).parseFromString(xmlStr, "text/xml");
        };
    } else if (typeof window.ActiveXObject != "undefined" &&
           new window.ActiveXObject("Microsoft.XMLDOM")) {
        parseXml = function(xmlStr) {
            var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = "false";
            xmlDoc.loadXML(xmlStr);
            return xmlDoc;
        };
    } else {
        throw new Error("No XML parser found");
    }
    

    Example usage:

    var xml = parseXml("[Your XML string here]");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following piece of code which tries to load an XML file from
I have the following snippet which i use to load xml via jQuery from
I have a class which loads an xml file using the following: Path.Combine( AppDomain.CurrentDomain.BaseDirectory,
I have the following code, in which Boost.Local uses a function callback to load
I have the following code which I use to load the xml object but
I have the following xml, from which I am trying to remove all xmlns
I have the following XML which I load via XDocument.Load(uri) or XElement.Load(uri) . I
I have the following code (from a previous question on this site) which retrieves
I have the following function which does a crude job of parsing an XML
I have the following code which loads and html file into a webview -

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.