PHP DOMDocument: How do I get the value of an input field

后端 未结 2 1176
执笔经年
执笔经年 2020-12-21 01:49

How do I get the value of an input field like the one below where it does not have an ID attribute using PHP\'s DOMDocument?



        
2条回答
  •  独厮守ぢ
    2020-12-21 02:35

    $dom = new DOMDocument();
    $dom->loadHTML($result);
    $xpath = new DOMXpath($dom);
    $node = $xpath->query('//input[@name="token"]/attribute::value');
    $token = $node->item(0)->nodeValue;
    

提交回复
热议问题