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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:09:35+00:00 2026-06-18T18:09:35+00:00

ok so my responseText contains an ‘&’ character which seems to cause problems when

  • 0

ok so my responseText contains an ‘&’ character which seems to cause problems when parsing. so I want to grab my responseText and change the ‘&‘ for ‘&‘

I’m aware responseText is a String and ideally I want to feed this back into the responseXML to parse with the new xml with &

any help much appreciated

            responseXML  = xmlhttp.responseXML;
        var myResponseText = "<document-metadata><item><name>ccms_customer_key</name><value>0100000931012004110</value></item><item><name>ccms_customer_name</name><value>Mr Joe Bloggs</value></item><item><name>ccms_customer_salutation_name</name><value>Mr</value></item><item><name>ccms_rm_name</name><value></value></item><item><name>ccms_dms_key</name><value>2432559OEKM</value></item><item><name>ccms_customer_address</name><value>Main & Street Dublin </value></item></document-metadata>";
        /*
        if(myResponseText.indexOf('&') >= 0)    
        {
            var str = myResponseText.replace(/&/g,"&amp;");
            return str;
        }
        */
        //old line getSession().setAttribute('LH_METADATA_XML',xmlhttp.responseText);
        getSession().setAttribute('LH_METADATA_XML',myResponseText);

        // extract COMP_DMS_KEY from metadata
        var root = responseXML.getElementsByTagName('document-metadata').item(0);
  • 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-18T18:09:36+00:00Added an answer on June 18, 2026 at 6:09 pm

    Why not parse the string in a completely different way, such as with DOMParser or (may be what you need due to the error) document.implementation.createHTMLDocument(""), or even just creating a HTMLDivElement and setting innerHTML?

    var doc = document.implementation.createHTMLDocument(""); // create a HTML document
    doc.body.innerHTML = "<document-metadata><item><name>ccms_customer_key</name><value>0100000931012004110</value></item><item><name>ccms_customer_name</name><value>Mr Joe Bloggs</value></item><item><name>ccms_customer_salutation_name</name><value>Mr</value></item><item><name>ccms_rm_name</name><value></value></item><item><name>ccms_dms_key</name><value>2432559OEKM</value></item><item><name>ccms_customer_address</name><value>Main & Street Dublin </value></item></document-metadata>";
    doc.body; // navigate to your root node from here
    

    Doing this (i.e. using text/html rather than application/xml) will mean that the parser is less strict and not be troubled by the & whilst retaining the ability to use DOM methods.

    From here you can now even re-serialize and convert this to a true XML document, say root is your root node

    var x = new XMLSerializer(), p = new DOMParser(), xml_string, xml_doc;
    xml_string = x.serializeToString(root); // now we have a valid string
    xml_doc = p.parseFromString(xml_string, 'application/xml'); // and now it is an XML document
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the whole html page in responseText, i just want to parse/
I have a small form which contains a first name, last name and a
I have a master page which contains everything that inherits it within a form.
I have a form that contains 5 drop down lists which are created by
The setup : The controller contains a method public ActionResult SaveFile() which returns a
I'm having some problems with getting to the object which is returned by one
Suppose I have a string which contains an HTML file. How do I get
I have some javascript: eval('var incomingJSON =' + ajaxObj.responseText); for (p in incomingJSON.common) {
var htm = $.ajax({ type: GET, url: ./viewforms, async: false }).responseText; var myObject =
I'm trying to figure out how I'd add a contains to check that the

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.