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

  • Home
  • SEARCH
  • 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 192055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:23:37+00:00 2026-05-11T16:23:37+00:00

Say you in JavaScript are handed a single DOM element or Document (for example

  • 0

Say you in JavaScript are handed a single DOM element or Document (for example window.document), how would you turn that into valid XML?

More specifically for my example, I have a web page that display’s an SVG, this SVG has a lot of JavaScript to allow interaction. It’s a graph display that let’s you zoom in the graph and even make some transformations. Now the users off this want’s to have a “Save image” button. The way I imagine doing this is to take the document node for the SVG element, and convert it into XML, then send that to the server, which then returns a page with the SVG document, or a PNG image.

This is all running on FireFox (which is currently a requirement for the users, though it works fine in Safari and Chrome as well). In firefox in the web page, I have included the SVG document as an Object element. In javascript I can access that objects contentDocument, that refers to the root off the XML page. It contains XML version, a Document tag, and the root svg tag with all attributes.

Maybe someone has already solved this, so I can copy their code. Perhaps someone knows where to look in firebug to achieve this. Or maybe there are already DOM methods for this.

  • 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-05-11T16:23:38+00:00Added an answer on May 11, 2026 at 4:23 pm

    There is a non-standard API object: XMLSerializer (it is not standard though is implemented in all but IE browsers).

    Its serializeToString method expects DOMNode object to be passed.

    var sXML = new XMLSerializer().serializeToString(document.body);
    

    In Internet Explorer there is no way to retrieve proper XML for HTML, unless getting .outerHTML and fixing all problems that come with serialization to HTML (such as missing quotes in attributes, not closed tags etc.)

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

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Because what it actually looks like after the compiler has… May 11, 2026 at 8:40 pm
  • Editorial Team
    Editorial Team added an answer If you decide that you want to render every 10… May 11, 2026 at 8:40 pm
  • Editorial Team
    Editorial Team added an answer I'd do it like this (String as key instead of… May 11, 2026 at 8:40 pm

Related Questions

This question deals with concurrency issues, for suggestions on how to display a busy
Usually, if you need to set a style attribute in JavaScript, you say something
In JavaScript, you can use Lazy Function Definitions to optimize the 2nd - Nth
Say you have a web form with some fields that you want to validate
JavaScript performance in Internet Explorer sucks. No news there. However there are some tips

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.