简体   繁体   中英

How to get php DOMDocument xpath of a select tag by name

I have the following html:

<select type="text" name="City" value="">
<option>city1</option>
<option>city2</option>
<option>city3</option>

i am trying to use DOMDocument's xpath to get the array of the cities. my xpath expression so far is:

$xpath = new DOMXPath($dom);
$nodeList = $xpath->query("//select[name=='City']/option"); 

This is not working and i can not figure out why.

Bill

尝试

$nodeList = $xpath->query("//select[@name='City']/option");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM