DOM question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ang Talunin

    #1

    DOM question

    Hey,

    I've got this code:

    var dataDate =
    document.create TextNode(x[q].childNodes[3].firstChild.nod eValue);
    var dataBody =
    document.create TextNode(x[q].childNodes[4].firstChild.nod eValue);

    and the first line works fine...but the second gives this error:
    x[q].childNodes[4].firstChild.nod eValue has no properties

    They are defined almost the same in the xml and i can't find the error

    anybody got a idea?

    A.T.

    ps. Mozilla gives the errors MIE not....


  • Yann-Erwan Perio

    #2
    Re: DOM question

    Ang Talunin wrote:
    [color=blue]
    > x[q].childNodes[4].firstChild.nod eValue has no properties[/color]
    [color=blue]
    > ps. Mozilla gives the errors MIE not....[/color]

    User agents treat white-spaces/new-lines differently, some add text
    nodes, some do not. Either remove any ws-nl, or (better) adopt a more
    defensive coding approach, don't use indexes, use tree walkers with
    filters or IDed elements.


    Regards,
    Yep.

    Comment

    • DU

      #3
      Re: DOM question

      Ang Talunin wrote:[color=blue]
      > Hey,
      >
      > I've got this code:
      >
      > var dataDate =
      > document.create TextNode(x[q].childNodes[3].firstChild.nod eValue);
      > var dataBody =
      > document.create TextNode(x[q].childNodes[4].firstChild.nod eValue);
      >
      > and the first line works fine...but the second gives this error:
      > x[q].childNodes[4].firstChild.nod eValue has no properties
      >
      > They are defined almost the same in the xml and i can't find the error
      >
      > anybody got a idea?
      >
      > A.T.
      >
      > ps. Mozilla gives the errors MIE not....
      >
      >[/color]

      What Yann-Erwan Perio replied you is correct.

      The MDN Web Docs site provides information about Open Web technologies including HTML, CSS, and APIs for both Web sites and progressive web apps.


      DU

      Comment

      Working...