PHP简单HTML DOM解析器如何获取非属性元素

PHP简单HTML DOM解析器如何获取非属性元素,php,simple-html-dom,Php,Simple Html Dom,TR中的HTML值为: <input type="radio" name="question_id[1111]" id="question_id[1111]" value="999" class="noborder" checked />Yes</div><div style="white-space:nowrap;margin-right:20px;display:inline-block;"> <input type="radio" name="q

TR中的HTML值为:

<input type="radio" name="question_id[1111]" id="question_id[1111]" value="999" class="noborder" checked />Yes</div><div style="white-space:nowrap;margin-right:20px;display:inline-block;">

<input type="radio" name="question_id[1111]" id="question_id[1111]" value="888" class="noborder" />No</div>

我只想确定哪一个结果包含“checked”。如果包含,它应该返回“value”。我可以使用
$input->“value
”获取value的值,但如何获取非元素的值?

未测试,但您可能应该尝试以下方法:

$html = str_get_html($results);

foreach($html->find('tr') as $tr)   
{               
   foreach($tr->find('input[checked]') as $input)
   {   
       print $input->'value';                             
   }
}

完美的解决了这个问题,并且使用了更少的代码。谢谢
$html = str_get_html($results);

foreach($html->find('tr') as $tr)   
{               
   foreach($tr->find('input[checked]') as $input)
   {   
       print $input->'value';                             
   }
}