Trying to Find the ParentNode

Discussion in 'Javascript' started by Michael Hill, Jan 15, 2004.

  1. Michael Hill

    Michael Hill Guest

    I am trying to get all the "polyline" tags and then find the parent node
    above it so I can transform it.

    var poly = svgDocument.getElementsByTagName("polyline");
    for ( var i=0; i < poly.length; i++ )
    {
    myobj=poly.parentNode(i);
    alert(i + myobj);
    }

    This is not working. Any help is appreciated.

    Mike
     
    Michael Hill, Jan 15, 2004
    #1
    1. Advertising

  2. "Michael Hill" <> wrote in message
    news:...
    >I am trying to get all the "polyline" tags and then find the
    >parent node above it so I can transform it.
    >
    > var poly = svgDocument.getElementsByTagName("polyline");


    I haven't had much to do with scripting the SVG DOM yet, but:-

    > for ( var i=0; i < poly.length; i++ )
    > {
    > myobj=poly.parentNode(i);


    In principal - poly - is a nodeList interface implementing object. In
    JavaScript/ECMA Script it should be posible to access numerically
    indexed members of a nodeList in the same way as an Array is accessed;-
    poly - or using the nodeList's - item - method - poly.item(i) - .
    That should return a reference to one of the "polyline" elements. It is
    those elements that may/should have a parentNode property, not the
    nodeList object.

    The object that represents the parentNode (if any) would be another
    element and almost certainly implemented as an object, not a function.
    So calling that property and passing - i - as a parameter to that
    function call doesn't make much sense. Probably you want something
    like:-

    myobj = poly.parentNode;


    > alert(i + myobj);


    If - i - is an integer and - myobj - refers to an object what do you
    expect to be the result of adding them together? You can type-convert
    them to strings and get the - + - operator to do concatenation by adding
    a string to that expression:-

    alert( i + " " + myobj);

    The result should also be clearer to read, as it will introduce a space
    between them.

    > }
    >
    >This is not working. Any help is appreciated.


    "This is not working" is rarely sufficient information to allow anyone
    to usefully comment on why something isn't working. You need, at the
    very least, to provide a context (testing/execution environment(s)) for
    it and some criteria for "working" and details of how failure to achieve
    that is manifesting itself. Particularly important are any error
    messages generated.

    Richard.
     
    Richard Cornford, Jan 15, 2004
    #2
    1. Advertising

  3. Michael Hill

    Jim Ley Guest

    On Thu, 15 Jan 2004 04:47:12 -0000, "Richard Cornford"
    <> wrote:

    >"Michael Hill" <> wrote in message
    >news:...
    >>I am trying to get all the "polyline" tags and then find the
    >>parent node above it so I can transform it.
    >>
    >> var poly = svgDocument.getElementsByTagName("polyline");

    >
    >I haven't had much to do with scripting the SVG DOM yet, but:-


    It's nice! You've got DOM 2,
    JScript, JavaScript (both rhino and spidermonkey) and KJS are all
    used by good SVG user agents, although it's a time when using the
    Compact Profile (ECMA 327 is it? - this could be FAQ'd actually?) as
    there are a lot of scriptable mobile user agents.

    There is an old SVG browser (ASV 2 in NN4) that doesn't have try/catch
    but all others do and you're probably safe to use it.

    >myobj = poly.parentNode;


    Yep!

    Jim.
    --
    comp.lang.javascript FAQ - http://jibbering.com/faq/
     
    Jim Ley, Jan 17, 2004
    #3
  4. "Jim Ley" <> wrote in message
    news:...
    <snip>
    >>I haven't had much to do with scripting the SVG DOM yet, but:-

    >
    >It's nice! You've got DOM 2, JScript, JavaScript
    >(both rhino and spidermonkey) and KJS are all used
    >by good SVG user agents, although it's a time when
    >using the Compact Profile (ECMA 327 is it? - this
    >could be FAQ'd actually?) as there are a lot of
    >scriptable mobile user agents.

    <snip>

    Yes, ECMA 327 is the Compact Profile and it probably does deserve a
    mention in the FAQ. Especially as it is only two pages on the features
    from ECMA 262 that do not need to be implemented in the Compact Profile.

    Richard.
     
    Richard Cornford, Jan 18, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    3,471
  2. NotGiven
    Replies:
    0
    Views:
    523
    NotGiven
    Sep 17, 2004
  3. RC
    Replies:
    1
    Views:
    1,327
    Martin Honnen
    May 31, 2007
  4. pxpilot

    XmlNode ParentNode???

    pxpilot, Feb 23, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    479
    Michael Nemtsev [MVP]
    Feb 23, 2008
  5. NotGiven
    Replies:
    0
    Views:
    102
    NotGiven
    Sep 16, 2004
Loading...

Share This Page