Re: [PHP] DOM Question. No pun intended.



Satyam,

I don't see any "innerHTML" or "outerHTML" in relation to PHP DOM. I'm familiar
with them from a Javascript standpoint, but no references when it comes to PHP
DOM.

Regards,
Mike


Quoting Satyam <Satyam@xxxxxxxxxxxxx>:

Try the properties innerHTML or outerHTML, the later will include the enclosing tag.

Satyam

----- Original Message ----- From: "Michael Williams" <mwilliams@xxxxxxxxxxxxxxxxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Thursday, September 14, 2006 2:12 AM
Subject: [PHP] DOM Question. No pun intended.


Hi All,

I'm having HTML DOM troubles. Is there any way to output the *EXACT*
code
contained in a node (child nodes and all)? For instance, I perform a
$doc->loadHTML($file) and all
is well. I then search through the document for specific NODEs with
getElementsByTagName(). However, when I go to output the data from
that node
(say a specific DIV) I simply get the text without formatting and the
like.
Basically, I want the retrieved NODE to echo exactly what is
contained. If the
div looks like the following:

<div id="name">
<table>
stuff
</table>
</div>

. . .I want it to give me exactly that when I do a NODE->textContent or
NODE->nodeValue. I don't want just the text, I want all tags
contained, etc.
It would be nice to have DOMNode->saveHTML() similar to the
DOMDocument->saveHTML().

FYI, I'm using the technique to "screen scrape" portions of other
pages from my
site and compile items for a quick fix. Fortunately all my DIVs have
IDs and I
can loop through and find them by that attribute's value. I just
can't output
their EXACT data once I have them. :-\

Thanks!


.



Relevant Pages

  • Re: domxml - parsing an xml file once per session rather than every time
    ... if we can shove a $dom in there and retrieve it. ... PHP object. ... create the DomDocument object for the PHP script to use. ...
    (comp.lang.php)
  • Interaction between SimpleXML & DOM
    ... I have a problem with the interaction between SimpleXML & DOM in Php. ... How can I load an external xml file and put it in a DOM document? ...
    (comp.lang.php)
  • Re: Resuming relative position of viewed dynamic page
    ... Jquery is made for that....it has Ajax built in as well. ... address almost any object in the DOM and change it. ... whether PHP had a solution... ...
    (comp.lang.php)
  • Re: PHP5 DOM API documentation?
    ... > I'm trying out PHP5, at long last it has EXCEPTIONS!!! ... > I'm used to the java DOM implementation, ... > Is there a set of API docs for PHP and XML? ... I too had a hard time finding documentation for PHP's DOM API. ...
    (alt.php)
  • grabbing HTML from within XML
    ... DOM with the innerHTML property of an existing tag or whatever. ... node may have an unknown number of child nodes) which ... I've tried wrapping the description in a <div> tag, ... I tried grabbing it with the firstChild property of my ...
    (comp.lang.javascript)