Loading ...
Sorry, an error occurred while loading the content.

SVG and DOM question

Expand Messages
  • gonzo4819
    I have an object made up of several SVG elements like this:
    Message 1 of 2 , Jun 4, 2009
    View Source
    • 0 Attachment
      I have an object made up of several SVG elements like this:

      <defs>
      <svg id="routerdef" ...
      <g>
      <ellipse .....
      <rect .....
      <ellipse ....
      <line ....
      <line ....
      <text id="comment" ..... > initial comment </text>
      </g>
      </svg>
      </defs>

      (I have used a new <svg> tag here because I want to
      be able to change the viewbox values separate from the
      background)

      I use this object multiple times like this:

      <use id="10.0.0.1" xlink:href="#routerdef" ....
      <use id="10.0.0.2" xlink:href="#routerdef" ....
      <use id="10.0.0.3" xlink:href="#routerdef" ....
      <use id="10.0.0.4" xlink:href="#routerdef" ....

      This is my question: How do I change the text comment of a specific
      instance of this object? This gets me the specific object:

      router = document.getElementById("10.0.0.2");

      but now I want to get access to the <text> tag of this specific
      object. This does not seem to work:

      var textNode = router.getElementById("comment");
      if (textNode) textNode.firstChild.nodeValue = "my new comment";

      How do I get access to this specific element so I can change
      this specific instance?

      I can get to the text comment of *all* of the objects like this:

      var textNode = document.getElementBytId("comment");
      if (textNode) textNode.firstChild.nodeValue = "my new comment";

      but this changes the comment for all of the instances.
      So, how do I change the text comment for each instance of the
      object?

      Thanks,

      -Andres
    • gonzo4819
      ... I am sorry folks. I did not see the responses to my original post about this issue so I just posted this question again--so you can ignore this post.
      Message 2 of 2 , Jun 4, 2009
      View Source
      • 0 Attachment
        --- In svg-developers@yahoogroups.com, "gonzo4819" <gonzo4819@...> wrote:
        >
        > I have an object made up of several SVG elements like this:


        I am sorry folks. I did not see the responses to my original
        post about this issue so I just posted this question again--so
        you can ignore this post.

        Thanks for the responses to my question.

        -Andres
      Your message has been successfully submitted and would be delivered to recipients shortly.