簡體   English   中英

PHP Simple HTML DOM解析器如何獲取非屬性元素

[英]PHP Simple HTML DOM Parser how to get non attribute element

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>

我的代碼是:

    $html = str_get_html($results);

    foreach($html->find('tr') as $tr)   
    {               
       foreach($tr->find('input') as $input)
       {   
          if ('not sure what to put here' == 'checked')
          {
           print $input->'value';  
          }                                 
       }
    }

我只想確定哪些結果包含“已檢查”。 如果是這樣,它將返回“值”。 我可以使用$input->'value '獲得value的值,但是如何獲取非element的值呢?

未經測試,但也許您應該嘗試以下方法:

$html = str_get_html($results);

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM