[RESOLVED] DOMNode - How to get the innerHTML?
So I've got a DOMNode object, let's say it's this:
HTML Code:
<div id="heading" >
<h1> <cufon> My Heading</cufon> </h1>
</div>
and I want to get this string:
HTML Code:
<h1> <cufon> My Heading</cufon> </h1>
I've get the div#heading as a DOMNode object, but I can't figure out/find a way for the life of me to just dump the contents......anybody?
I've switched careers...
I'm NO LONGER a scientist,
but now a web developer...
awesome.
PHP Code:
$xml = <<<EOQ
<div id="heading">
<h1><cufon>My Heading</cufon></h1>
</div>
EOQ;
$dom = new DOMDocument ();
$dom -> loadXML ( $xml );
echo $dom -> saveXML ( $dom -> getElementsByTagName ( 'h1' )-> item ( 0 ));
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
—Tim Berners-Lee, W3C Director and inventor of the World Wide Web
I'm not sure, but I don't think there's a PHP DOM corollary to the (non-standard) JavaScript innnerHTML. Maybe something like the following?
PHP Code:
$heading = $dom -> getElementById ( 'heading' ); $cufonList = $heading -> getElementsByTagName ( 'cufon' ); foreach( $cufonList as $cufon ) { echo $cufon -> textContent ; }
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
I've switched careers...
I'm NO LONGER a scientist,
but now a web developer...
awesome.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks