title: PHP XPath to determine if a checkbox is checked?
body: <p>On a website it has a checkbox HTML code like this:</p>
  <pre><code>&lt;input type=&quot;checkbox&quot; name=&quot;mycheckbox&quot; id=&quot;mycheckbox&quot; value=&quot;123&quot; checked=&quot;checked&quot;&gt;
  </code></pre>
  <p>How do I check if the checkbox is already checked via the <code>xPath</code>? I essentially just want a boolean telling me True if it is checked. I am unsure how to get this though.</p>
  <pre><code>&lt;?php
  
  $dom = new DOMDocument();
  $content = file_get_content('https://example.com');
  @$dom-&gt;loadHtml($content);
  
  // Xpath to the checkbox
  $xp = new DOMXPath($dom);
  $xpath = '//*[@id=&quot;mycheckbox&quot;]'; // xPath to the checkbox
  $answer = $xp-&gt;evaluate('string(' . $xpath . ')');
  </code></pre>