title: Get the current ID of parent element using domXpath
body: <p>I'm working on getting the ranking of a domain on baidu.</p>
  
  <p>What I'm trying to do is get the position of the result when the domain appear, I manage to get the domain name, my problem is the position. </p>
  
  <p>I need to get the <code>id</code>(this is the position) of the <code>result c-container</code> when the domain appears on the result. hope you help me.</p>
  
  <p>thanks.</p>
  
  <pre><code>$finder = new DomXPath($document);
          $results = $finder-&gt;query("//*[contains(@class, 'result c-container')]");
  
          if($element){
  
              $data = array();
  
              foreach ($results as $result) {
                  # code...
  
  
                  $as = $result-&gt;getElementsByTagName('a');
                  foreach ($as as $a){
                      if ($a-&gt;getAttribute('class') === 'c-showurl') {  
                          $textUrl = $a-&gt;nodeValue;
  
                          if (($pos = strpos($textUrl, "}")) !== FALSE) { 
                              $textUrl = substr($textUrl, $pos+1); 
                          }
  
                          $domain = trimUrl($domain);
  
                          if(preg_match("/{$domain}/i", $textUrl)) {
                              $data['domain'] = $textUrl;
                              $data['id'] = ?
                          }
  
  
                      }
                  }
  
              }
  
              array_push($res, $data);
  
          }else{
              $data = array();
              array_push($res, $data);
          }
  </code></pre>