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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:30:10+00:00 2026-06-07T04:30:10+00:00

TL/DR: How to load an XML response via FormPanel reliably? We have a web

  • 0

TL/DR: How to load an XML response via FormPanel reliably?


We have a web application in GWT using Sencha GXT for most of the UI. We use a GXT FormPanel to upload a file to a server-side script (which just echoes the file’s contents) to get a local file’s contents in JS. Eventually this can be done with FileReader, but obviously not in browsers that don’t support that.

The FormPanel submits its form and loads the result in a hidden IFrame from which the contents are extracted with the following snippet (from FormPanelImpl.class):

try {
  // Make sure the iframe's window & document are loaded.
  if (!iframe.contentWindow || !iframe.contentWindow.document)
    return null;

  // Get the body's entire inner HTML.
  return iframe.contentWindow.document.body.innerHTML;
} catch (e) {
  return null;
}

We’re loading an XML file that way and the problematic line is

return iframe.contentWindow.document.body.innerHTML;

because the XML is loaded as XML (and thus not embedded in a HTML wrapper) in a few cases. I tried the following:

  1. I used Content-Type: text/html originally (oversight in the local PHP test script, error on my part in the production code). Worked in Firefox and Chrome but not in IE (9) where the XML was loaded as XML in the IFrame instead.
  2. Content-Type: application/xml which would be the correct one for the payload. Now it doesn’t work anywhere because we now get the behaviour that originally only IE exhibited in Chrome and FF too.
  3. Content-Type: application/octet-stream: Not a good idea, it just downloads the file.
  4. Content-Type: text/plain: I was hoping this would always trigger the HTML/body wrapping and it does, but it also wraps everything in a pre element so it now fails everywhere, but that at least reliably. Great.

After a little digging I found out that apparently the GXT FormPanel uses the same FormPanelImpl from GWT so results are identical for both anyway. And GWT’s documentation says (which Sencha wisely withheld):

The back-end server is expected to respond with a content-type of 'text/html', meaning that the text returned will be treated as HTML. If any other content-type is specified by the server, then the result html sent in the onFormSubmit event will be unpredictable across browsers, and the FormHandler.onSubmitComplete(FormSubmitCompleteEvent) event may not fire at all.

However, even with sending text/html the behaviour is unpredictable across browsers if the payload is XML.

Is there a general solution to this? Or am I missing something terribly trivial (I’m looking at GWT for just three days now)?

EDIT: I tried prepending <html><body> to the file contents so even IE would have a body in the IFrame. Well, it did, but it also resulted in a very, very strange innerHTML starting with:

<?XML:NAMESPACE PREFIX = [default] ...

which the XML parser understandably chokes on.

  • 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-07T04:30:11+00:00Added an answer on June 7, 2026 at 4:30 am

    My guess is that in general, wrapping XML in an HTML context without performing any escaping of special characters doesn’t work reliably. I would expect it to fail at least with an XML document like

    <a>
      <b>
        <html>
        </html>
      </b>
    </a>
    

    The approach we took is to just send back a small “OK” message, and then use a separate request to get the (cached) contents from the server.

    Alternatively, it would probably be possible to perform HTML encoding/decoding (or Base64, …)

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

Sidebar

Related Questions

I want to use an NSURLConnection in my application to load an XML response
im developing an GUI Application, using JSWing, i load XML file, then deserialize it,
I have a class that I instantiate to save or load xml data. For
I'm trying to use the following code # LOAD XML FILE $XML = new
I need to load an XML source using Simple XML, duplicate an existing node
I have the following XML Parsing code in my application: public static XElement Parse(string
I am using below code to load a xml: XmlDocument xdoc = new XmlDocument();
I want to use this gem in my api application https://github.com/seangeo/auth-hmac/ I have a
I have a big xml file which i'm parsing using jscript. I have used
I have a SWF loaded via a swfobject.embedSWF() I use Javascript's methods to pass

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.