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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:06:54+00:00 2026-06-11T01:06:54+00:00

I have a page that is getting an XML document in order to add

  • 0

I have a page that is getting an XML document in order to add a form to the page.
My XML structure is, simplified as much as possible, along these lines:

<root><someXMLElement><input type="text"></input></someXMLElement></root>

I can get the xml string without any problems, and this all works fine in Chrome, FireFox, IE10 but when I open the page in IE8 on another machine or IE10 compatibility view, my XML is being transformed to an unusable state, like so:

<DIV><INPUT type=text></INPUT/></HOFCDHIDDENINPUTS/></ROOT/></DIV>

I was originally getting my XML response and trying to dynamically handle parsing through it without placing it first in the DOM of my document, along the lines of :

var xml = http.responseText;
var xmlElements = $(xml).filter("root").html();
...do work on xmlElements 

but neither $(xml).filter or $(xml).find returned any value in IE8. This seemed rather similar to:
jQuery .find() doesn't return data in IE but does in Firefox and Chrome
however this problem persists even when I write my xml inline without using ajax, and simply trying to use the jQuery ParseXML or an ActiveX parser did nothing to solve the issue. The parsed XML still returned nothing from find().
I have read in several places about IE8 woes surrounding innerHTML, so I opted for an alternate solution to a dynamic DOM in a variable. Instead, I created an element using document.createElement, added my response to this element’s innerHTML, and then appended this to the document itself, along the same lines as http://domscripting.com/blog/display/99, with a simplified version of my code being as follows:

$(document).ready(function () {
            var XMLContainer = document.createElement("div");
            XMLContainer.innerHTML
= "<root><someXMLElement><input type=\"text\"></input></hofcdhiddeninputs></root>"
            document.body.appendChild(XMLContainer);
            var DOMAccessibleXML = $("body").find("root").html();

or
var DomAccessibleXML = document.body.getElementsByTagName[0].innerHtml
});

I also tried using innerText, as well as creating the element with jQuery and using the append() function. The result was the same all around. My XML was added to the element on my page, however it was transformed at some point in the append to look like:

This simple XML isn’t too badly damaged, but even here it adds forward slashes to the end of every element. In some cases it would leave elements out entirely (in the case of empty elements) or simply delete the opening tag (no idea). The fact that this happens with or without jQuery and only in IE8 leads me to believe that it is happening during the append. As a side note, if you alert the above DomAccessibleXML, it comes up blank, showing my prior issue.

So, what I need is the ability to traverse and manipulate the DOM of an XML document using javascript and jQuery if possible. If the solution is to add teh XML to the page at hand first, I need a way to not have IE8 mangle it. If the solution is to create a dynamic DOM I need a way to have jQuery find() get results, or an alternate method of retrieving values without jQuery find or filter.

Thanks very much for your consideration.

Edit 1: Windows 7, IE8.0.7601, IIS 7.5.7600, issue present in jQuery 1.8.0 and 1.5.2

Edit 2: I can get the XML to parse now by adding an xml declaration to my example code, but I still cant access innerHTML or getElementsByTagName. In the code below, xmlDoc.documentElement.xml returns the correct string, while xmlDoc.documentElement.getElementsByTagName(“root”).length returns 0. At this point, I believe I could accomplish this in pure DOM manipulation avoiding innerHTML, but I would very much prefer to not rewrite everything with this constraint.

var XMLContainer = document.createElement("div");
            var XMLContainer = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><root><someXMLElement><input type=\"text\">text</input></someXMLElement></root>";
            var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = false;
            xmlDoc.loadXML(XMLContainer);
            alert(xmlDoc.documentElement.xml);
            alert(xmlDoc.documentElement.getElementsByTagName("root").length);

edit 3: doh! documentElement refers to root. getElementsByTagName(‘someXMLElement’) works as expected. If I can get my larger document to parse this should work, but innerHTML issues aside I would still like to know why IE8 mangles the elements on append. Any thoughts?

  • 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-11T01:06:55+00:00Added an answer on June 11, 2026 at 1:06 am

    XML documents are not HTML documents. Do not try to append XML nodes into an HTML document; it won’t work unless the XML elements just happen to correspond to a valid HTML structure with respect to the element names and their hierarchy, which yours does in part, but only in part.

    You should be able to manipulate the XML directly with jQuery however. Just say,

    var jQueryXmlObject = $($.parseXML("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><root><someXMLElement><input type=\"text\">text</input></someXMLElement></root>"));
    

    And you’ve got a jQuery object on which you can use .find() or whatever to your heart’s content. But note that .filter('root') still won’t work – this is because the jQuery object refers to the document, not the root element. .filter does not search the DOM, it only reduces the set of “matched elements” in a jQuery object, which is not applicable here.

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

Sidebar

Related Questions

I have a page that looks like this: Head and body tags... <form runat=server>
So I have a page that is accepting XML through a POST method. Here's
I have a page on a remote server that returns a single xml value
I want to send an xml document that i have created using jdom api.
I am having trouble getting the page to work. I have my form method
i have an ASP.net page that generates dynamic xml but the get statement of
I have a page that builds out a table. Nothing else on that page
I have a page that lets the user edit the content of the page
I have a page that uses the Telerik RadListView control and a Telerik RadDataPager
I have a page that I want to update non stop, every few seconds.

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.