www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] DOMNode - How to get the innerHTML?

  1. #1
    Join Date
    Dec 2005
    Posts
    2,984

    resolved [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.

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    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

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,178
    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

  4. #4
    Join Date
    Dec 2005
    Posts
    2,984
    You folks rock!
    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
  •  
HTML5 Development Center



Recent Articles