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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:17:13+00:00 2026-06-05T23:17:13+00:00

I am creating an XML string using JQuery. I would like to open a

  • 0

I am creating an XML string using JQuery. I would like to open a new window to display this string to the user in order he saves it as an XML file.

I do not have a server side and I would like this Javascript script to be compatible with either Firefox and Internet Explorer browsers.

I found a lot of stuff but nothing works really well.

uriContent="data:application/xml," + encodeURIComponent(xmlContent);
var newWindow=window.open(uriContent,'_blank','toolbar=0,location=0,directories=0,status=0, scrollbars=1, resizable=1, copyhistory=1, menuBar=1, width=640,height=480, left=50, top=50');

or for IE:

var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xmlContent);
var newWindow = window.open('','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=1, menuBar=1, width=640, height=480, left=50, top=50', true);
 newWindow.document.writeln(xmlDoc.documentElement.xml);
 newWindow.document.close();

The first solution works almost fine for Firefox but not for IE:

a data: url in FF

The second source code opens a window with the XML content but IE does not recognize it as XML… So the user has to display the source code by himself. This is not very convenient.

empty IE window

Does anyone have a solution?

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-05T23:17:14+00:00Added an answer on June 5, 2026 at 11:17 pm

    What if you treat the XML as content?

    var newWindow = window.open('','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=1, menuBar=1, width=640, height=480, left=50, top=50', true);
    var preEl = newWindow.document.createElement("pre");
    var codeEl = newWindow.document.createElement("code");
    codeEl.appendChild(newWindow.document.createTextNode(xmlContent));
    preEl.appendChild(codeEl);
    newWindow.document.body.appendChild(preEl);
    

    … then you can use something like Google Code Prettify or SyntaxHighlighter to add whatever highlighting you need.

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

Sidebar

Related Questions

I'm creating xml-like mark-up language using System.Xml.XmTextWriter that will be read by a third
I'm creating an XML document. I got it to indent using TransformerFactory.setAttribute(indent-number, new Integer(2));
I am creating an xml file on the fly. When a user generates this
I'm using xmlwriter to create an xml document. The xml document looks like this:
I'm using a simple ajax-enabled WCF service. I'm creating a string of XML on
I'd like to transform a string that contains an xml using a XSLT, it's
I am using Java back end for creating an XML string which is passed
Right, so this is my first day using XML. I'm not creating the XML,
I am creating serialized XML for a LINQ to SQL project using the DataContractSerializer
I'm creating an XML file using Perl and XML::Simple module. I successfully create 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.