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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:14:15+00:00 2026-06-01T06:14:15+00:00

I want to retrieve declared SVG attributes programmatically. It’s all inline content, something like

  • 0

I want to retrieve declared SVG attributes programmatically. It’s all inline content, something like this:

<svg>
<path d="###########">
    <animate from="5" to="0" begin="3s" dur="1s" etc etc>
</path>
</svg>

Sounds easy peasy, right? But I’m hitting a wall. I’ve read this, but for starters:

document.getElementsByTagName('path');

doesn’t seem to work in IE, which is the major trouble spot. It always returns undefined.

(I am aware that IE only supports scripted animation, that’s the whole occasion for this.)

Anyways, the “get” part works in Chrome, but when this Nodelist is logged in Dev Tools the console returns an unhelpful

[object Nodelist]

and when I log individual paths I get a similar:

[object Text]

which is all too similar to IE, and not the usual detailed javascript object, making it hard to tell what’s happening under the hood. Lastly, when I try to retrieve the declared attributes of the animation:

.getAttributeNS(null, 'dur')

doesn’t seem to work either, even in Chrome. Dev Tools says that the path object text has no ‘getAttributeNS’ method. Ditto for plain old ‘getAttribute’. I’ve also tried “.contentDocument” on the SVG file but that doesn’t work either. Basically, I have no trouble at all setting these values in any browser a la:

animation.setAttributeNS(null,'begin',startTimeRounded + 's');

I just can’t seem to get them. Any guidance highly appreciated.

P.S. jQuery selectors don’t work on SVG elements, and besides I’d rather not have to load a library to address this one little issue.

P.P.S. I’m iterating over an enormous quantity of paths, so answers that suggest setting unique IDs for each element aren’t helpful in this case. I want to get the elements by name. Cross-browser is best, but it must work in IE…

  • 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-01T06:14:16+00:00Added an answer on June 1, 2026 at 6:14 am

    The getElementsByTagName and SVG’s getAttribute elements seems to work fine with IE. Perharps you are trying to get the ‘dur’ attribute from the path element instead of from the animate element? Or else, from a text node of the ‘path’ element?

    SVG is quite strict regarding text nodes. For instance, if your path is defined like that:

    <path d="M 0 0 L 10 5 L 0 10 z" >
      <animate from="5" to="0" begin="3s" dur="1s">
    </path>
    

    It will consider that the first child of the ‘path’ element is a text node, while the second is the ‘animate’ you want. Thus, the following code should work

    var paths = document.getElementsByTagName('path');
    alert(paths[0].childNodes[1].getAttribute("dur")); //first path, second node ('animate'), the dur attribute
    

    However, if you define everything without any space between ‘path’ and ‘element’:

    <path d="M 0 0 L 10 5 L 0 10 z" ><animate from="5" to="0" begin="3s" dur="1s"></path>
    

    Then the animate will be the first child of ‘path’ and the following code will run ok:

    var paths = document.getElementsByTagName('path');
    alert(paths[0].childNodes[0].getAttribute("dur")); //now we can get the first child, as expected
    

    PS: this ‘animate’ will do nothing, as it is incomplete

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

Sidebar

Related Questions

I have a HTML table as follows. I want retrieve row values from this
I want to retrieve stack trace from a user dump file programmatically . There
I want to retrieve all records from one table when there are no matches
I want to retrieve all objects (not DOM elements) of a given type created
I have declared a map like this map<long long, list<SoundInfo *> > m_soundListMap; and
i have a TDictionary declared like so TDictionary<String,Integer> , Now i want to get
I want to retrieve data from stored procedure in table format like normal sql
I want retrieve the width and height of browser in pixel(px) using ruby code.
I want to retrieve a list of people's names from a queue and, for
I want to retrieve the moth from a date(in textbox),then If that retrieved month

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.