i am using the php dom function nodeValue to extract the text of content. But it returns the descendant values too:
<example>
<inhalt>123<more>45</more></inhalt>
</example>
return for inhalt 12345 and 123 as i prefer. I know that is not the sense and not very well to have text inside inhalt but how i check that there is no text in inhalt like hasNodeValue?
As Phil mentioned text is also organized in nodes. Therefore your node inhalt has two children: A text node (“123”) and an element node named more, which also has a text node (“45”).
If you just want to know, if there is text before the element more, test if there is at least one element and then test if the first element is text (should be DOMText as far as I remember).
If you like to know, if there is at least one element “at the root”, iterate over all children and make the same tests.
http://www.php.net/manual/en/class.domtext.php