Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 22nd, 2005, 12:05 AM
Fabien M
Guest
 
Posts: n/a
Default 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.



  #2  
Old November 22nd, 2005, 12:05 AM
Janwillem Borleffs
Guest
 
Posts: n/a
Default 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>some text <a href="...">link</a>';
$html .= '<span> some text2</span></div></html>';
$dom = new DomDocument;
$element = $dom->loadHTML($html);

$div = $dom->getElementsByTagName('div')->item(0);
print htmlentities($dom->saveXML($div));

?>


JW



  #3  
Old November 22nd, 2005, 12:05 AM
Fabien M
Guest
 
Posts: n/a
Default Re: Problem about DOMNodes Value

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

Thanks a lot, it works fine :D
  #4  
Old November 22nd, 2005, 12:05 AM
unlimitedbro@gmail.com
Guest
 
Posts: n/a
Default Re: Problem about DOMNodes Value

excellent reply I learned something tonight :)

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.