0

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.

2 Answers 2

1

//input[contains(@name,'ctl00$ctl00$mainContent$bodyContent$chkRitira_')]

Sign up to request clarification or add additional context in comments.

Comments

1

There is a starts-with that you can implement as below

//input[starts-with(@id, "ctl00$ctl00$mainContent$bodyContent$chkRitira_")]/@name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.