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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:31:10+00:00 2026-05-29T05:31:10+00:00

I wrote javascript which dynamically edits an svg element. I want to get the

  • 0

I wrote javascript which dynamically edits an svg element. I want to get the new string of the edited svg element but currently my code fails.
I found here the following code to get the string form of an HTML document.

var txt = document.documentElement.innerHTML;

I just want the innerHTML of the SVG element. I tried the following code but get an error message saying “undefined”.

var svgnode=document.getElementById("svgnode1");
alert(svgnode.innerHTML);

How do I do that. The error occurs on Google Chrome but I want a solution that works on any browser.

  • 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-29T05:31:10+00:00Added an answer on May 29, 2026 at 5:31 am

    innerHTML is defined for HTML documents but not for XML DOMs of other kinds.

    There is some mechanism planned for innerHTML like facilities for SVG. http://www.w3.org/Graphics/SVG/WG/wiki/SVG_2_DOM#innerHTML_type_facilities:

    innerHTML type facilities

    It would be good if XML had an innerHTML-like feature. Writing markup in an ECMAScript string can be a bit of a pain, but it can also simplify things a lot, and to get better that that for the types of scenario in which it’s useful probably means E4X-like capabilities.

    Calling this facility innerHTML would make it seem like the markup should be parsed as being in the XHTML namespace, so maybe innerMarkup or insertCode would be a better name, or, for symmetry with textContent, maybe markupContent.

    If what you need is a way to turn SVG, or any other XML DOM into a string of XML, see https://developer.mozilla.org/en/Parsing_and_serializing_XML

    • XMLSerializer to serialize DOM trees to strings

    or see https://stackoverflow.com/a/4916895/20394 for the IE equivalent.

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

Sidebar

Related Questions

I have some Javascript code that needs to be dynamically created as a String
If I write some JavaScript that runs in an <iframe> (which is dynamically created
I wrote a simple javascript image rotator which picks a random image on each
I have a javascript which I didn't write but I need to use it
I have a large javascript which I didn't write but I need to use
I recently wrote some javascript code that filled a drop down list based on
I need to compare two calendar dates. I wrote the javascript function too. But
I'm converting a Javascript program I wrote into Java, and there's one Object which
I wrote some html/css/javascript code that was taken verbatim from a javascript textbook. For
I wrote a sample html which retrieves the JSON from servlet and displays. But

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.