Reputation: 597
I would like to extract in an html page all the attribute names that start with ctl00$ctl00$mainContent$bodyContent$chkRitira_ and check if the input tag is checked. For example I have this piece of html code:
<tr>
<td operazione="ritira"><input id="ctl00_ctl00_mainContent_bodyContent_chkRitira_852428" type="checkbox" name="ctl00$ctl00$mainContent$bodyContent$chkRitira_852428" /><label for="ctl00_ctl00_mainContent_bodyContent_chkRitira_852428">Ritira</label></td>
</tr>
<tr>
<td operazione="ritira"><input id="ctl00_ctl00_mainContent_bodyContent_chkRitira_852429" type="checkbox" name="ctl00$ctl00$mainContent$bodyContent$chkRitira_852429" /><label for="ctl00_ctl00_mainContent_bodyContent_chkRitira_852429"> Ritira</label></td>
</tr>
I want to check if every input check that starts with ctl00$ctl00$mainContent$bodyContent$chkRitira_ is checked and the name of the attribute, then:
ctl00$ctl00$mainContent$bodyContent$chkRitira_852428
ctl00$ctl00$mainContent$bodyContent$chkRitira_852429
I tried with:
$xpR=new DOMXPath( $dom_richieste_r );
$colR = $xpR->query( '//input[@name="ctl00$ctl00$mainContent$bodyContent$chkRitira_"]' );
But this gives me back the content of the node.
Upvotes: 0
Views: 71
Reputation: 52665
There is a starts-with
that you can implement as below
//input[starts-with(@id, "ctl00$ctl00$mainContent$bodyContent$chkRitira_")]/@name
Upvotes: 1
Reputation: 56
//input[contains(@name,'ctl00$ctl00$mainContent$bodyContent$chkRitira_')]
Upvotes: 1