RE: Using DOM textContent Property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> if a node has children, then its not a leaf, so i imagine
> you could continue to traverse until you reach the leaf
> that actually has the address needing magical conversion.

I tried that.  $Element->hasChildNodes() returns true for just about
everything except tags like <br> and <img> that have no corresponding </br>
or </img> because the content that appears between <p> and </p>, for
example, apparently counts as a child node, even though they're not HTML
tags.  So, if you have:

<p>Foo!</p>

when you look at $Element->hasChildNodes() for the <p> tag, you will get
"true", and $Element->childNodes->length is equal to "1", even though "Foo!"
isn't an HTML tag.  Interestingly though, when you iterate through the tree,
you get the <p> tag as one of the elements, but you never get a text-only
element that has that <p> as a parentNode.  In fact, get_class($Element)
always returns DOMElement, even on the text-only nodes, which I would have
expected to be DOMText elements...but I guess not.  So I'm wondering why
$Element->hasChildNodes() would return true, but iterating through the DOM
tree returns no elements that have that $Element as a parentNode.

What's more, looking at $Element->childNodex->length isn't too helpful,
because, for example:

<h2><a name="bar"></a>Foo</h2>

returns two child nodes, neither of which has "Foo" for its textContent.

Tim Gustafson
SOE Webmaster
UC Santa Cruz
tjg@xxxxxxxxxxxx
831-459-5354



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux