<p>I'm parsing XML results from an API call using PHP and xpath.  </p>

<pre><code> $dom = new DOMDocument();
 $dom-&gt;loadXML($response-&gt;getBody());

 $xpath = new DOMXPath($dom);
 $xpath-&gt;registerNamespace("a", "http://www.example.com");

 $hrefs = $xpath-&gt;query('//a:Books/text()', $dom);

 for ($i = 0; $i &lt; $hrefs-&gt;length; $i++) {
      $arrBookTitle[$i] = $hrefs-&gt;item($i)-&gt;data;
 }

 $hrefs = $xpath-&gt;query('//a:Books', $dom);

 for ($i = 0; $i &lt; $hrefs-&gt;length; $i++) {
      $arrBookDewey[$i] = $hrefs-&gt;item($i)-&gt;getAttribute('DeweyDecimal');
 }
</code></pre>

<p>This works but is there a way I can access both the text and the attribute from one query?  And if so how do you get to those items once query is executed?</p>

Could you query for the concatenation?
```
```
$xpath->query('concat(//a:Books/text(), //a:Books/@DeweyDecimal)', $dom);
```
```
XSLT is an expression language in itself, and you can construct whatever specific format of return value you want from within the expression.