DOM question - visiting a node's children?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • r_topor@yahoo.com

    #1

    DOM question - visiting a node's children?

    As of PHP 5.1, why aren't there functions that return a node's
    children, a node's first/last/nth child, a node's parent/previous
    sibling/next sibling, etc., as in the DOM specification? How are you
    currently meant to traverse a DOM tree without these functions? Or
    perhaps they exist somewhere in the documentation, but not under the
    list of DOM functions - if so, where are they?

    Rodney

  • Erwin Moller

    #2
    Re: DOM question - visiting a node's children?

    r_topor@yahoo.c om wrote:
    [color=blue]
    > As of PHP 5.1, why aren't there functions that return a node's
    > children, a node's first/last/nth child, a node's parent/previous
    > sibling/next sibling, etc., as in the DOM specification? How are you
    > currently meant to traverse a DOM tree without these functions? Or
    > perhaps they exist somewhere in the documentation, but not under the
    > list of DOM functions - if so, where are they?
    >
    > Rodney[/color]

    Hi Rodney,

    That is like asking: "Where are the rocket blueprints for the Saturn5 in
    PHP?"

    PHP is executed at the server, and returns a response, which can be HTML.
    If you want to use DOM-specific functionality, this is executed by the
    browser that receives the HTML produced by PHP.

    PHP is completely out-of-touch with the HTML it delivered.

    You need Javascript to access DOM in a browser.

    Of course, this doesn't mean PHP cannot be used to deliver nice
    Javascript/HTML/etc, but PHP is NOT in charge anymore once the HTML arrives
    at some client (browser).

    Regards,
    Erwin Moller

    Comment

    • Kimmo Laine

      #3
      Re: DOM question - visiting a node's children?

      "Erwin Moller"
      <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote in
      message news:4469919e$0 $31644$e4fe514c @news.xs4all.nl ...[color=blue]
      > r_topor@yahoo.c om wrote:
      >[color=green]
      >> As of PHP 5.1, why aren't there functions that return a node's
      >> children, a node's first/last/nth child, a node's parent/previous
      >> sibling/next sibling, etc., as in the DOM specification? How are you
      >> currently meant to traverse a DOM tree without these functions? Or
      >> perhaps they exist somewhere in the documentation, but not under the
      >> list of DOM functions - if so, where are they?
      >>
      >> Rodney[/color]
      >
      > Hi Rodney,
      >
      > That is like asking: "Where are the rocket blueprints for the Saturn5 in
      > PHP?"
      >
      > PHP is executed at the server, and returns a response, which can be HTML.
      > If you want to use DOM-specific functionality, this is executed by the
      > browser that receives the HTML produced by PHP.
      >
      > PHP is completely out-of-touch with the HTML it delivered.
      >
      > You need Javascript to access DOM in a browser.[/color]

      While I agree with the fact that the question was a bit odd, I think it
      could actually mean another DOM tree, such as an XML DOM instead of HTML.
      Perhaps the original poster is referring to some XML parser, who knows.
      Point is that HTML isn't the only possibility here.

      --
      "ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
      spam@outolempi. net | Gedoon-S @ IRCnet | rot13(xvzzb@bhg byrzcv.arg)


      Comment

      • Rodney Topor

        #4
        Re: DOM question - visiting a node's children?

        Yes, I'm talking about XML DOM. See Section VI-XXX. DOM Functions and
        SectionVI-CLXVIII. XML Parser Functions, etc. As I understand it, all
        these functions are used in PHP scripts on the server to process XML
        documents as DOM trees in memory. (I'm not referring to HTML DOM which
        is indeed used by JavaScript on the client.)

        Comment

        • tim

          #5
          Re: DOM question - visiting a node's children?


          Rodney Topor wrote:[color=blue]
          > Yes, I'm talking about XML DOM. See Section VI-XXX. DOM Functions and
          > SectionVI-CLXVIII. XML Parser Functions, etc. As I understand it, all
          > these functions are used in PHP scripts on the server to process XML
          > documents as DOM trees in memory. (I'm not referring to HTML DOM which
          > is indeed used by JavaScript on the client.)[/color]

          Hi Rodney

          In the DOM functions childNodes,firs t/lastChild and parentNode are
          properties of DomNodes

          They are listed in the table just below the function list


          You're not the only one who a problem finding them. I searched the
          table of contents for ages wondering how I could use a dom without
          childNodes...

          Tim

          Comment

          • Rodney Topor

            #6
            Re: DOM question - visiting a node's children?

            Tim, Thank you! That answers my question. Glad to learn I am not
            alone. Case closed!

            Rodney

            Comment

            Working...