Problem about DOMNodes Value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fabien M

    #1

    Problem about DOMNodes Value

    Hello,
    i'm working on a script which uses DOM fonctions of PHP5.
    I've got a Node which looks like that :
    <div>some text <a href="...">link </a><span> some text2</span></div>

    When I use nodeValue, php returns "some text link some text2".
    How can I get all childs of this node?
    If you prefer, which method to use to get "<div>some text <a
    href="...">link </a><span> some text2</span></div>" ?

    Thanks a lot.
  • Janwillem Borleffs

    #2
    Re: Problem about DOMNodes Value

    Fabien M wrote:[color=blue]
    > i'm working on a script which uses DOM fonctions of PHP5.
    > I've got a Node which looks like that :
    > <div>some text <a href="...">link </a><span> some text2</span></div>
    >
    > When I use nodeValue, php returns "some text link some text2".
    > How can I get all childs of this node?
    > If you prefer, which method to use to get "<div>some text <a
    > href="...">link </a><span> some text2</span></div>" ?
    >[/color]

    <?php

    $html = '<html><div>som e text <a href="...">link </a>';
    $html .= '<span> some text2</span></div></html>';
    $dom = new DomDocument;
    $element = $dom->loadHTML($html );

    $div = $dom->getElementsByT agName('div')->item(0);
    print htmlentities($d om->saveXML($div)) ;

    ?>


    JW



    Comment

    • Fabien M

      #3
      Re: Problem about DOMNodes Value

      Janwillem Borleffs a écrit :
      [color=blue]
      > print htmlentities($d om->saveXML($div)) ;[/color]

      Thanks a lot, it works fine :D

      Comment

      • unlimitedbro@gmail.com

        #4
        Re: Problem about DOMNodes Value

        excellent reply I learned something tonight :)

        Comment

        Working...