PHP DOM: Get NodeValue excluding the child nodes
问题 I have a variable $content containing a piece of HTML code : <b>AMZN 466.00 ( 15743 ) ( <span class='red'> -1 </span>) MSFT 290.00 ( 37296 ) ( <span class='red'> -2 </span>) TWTR 4,000.00 ( 20 ) ( <span class=''> 0 </span>)</b> Now, I want the values of <b> excluding the values of <span> using PHP DOM. How can this be done? A code snippet would be helpful. So far, I've tried this: $dom = new domDocument; @$dom->loadHTML($content); $contents_i_want = $dom->getElementsByTagName('b'); foreach(