Get the text content of a node, but ignore child nodes

domdocument, php

Solution

Use `firstChild` :

$foo->firstChild->textContent;

Problem

``` <foo> a <bar> b </bar> </foo> ``` both `$foo->textContent` and `$foo->nodeValue` return `a b`. How can I get just `a` (the text from the node, without text from any child nodes)

Original source

Related problems