select whole node with its attribute value too with xpath
<p>hello Everyone i have a strange question (for me its strange). i have an xml file
like below:</p>

<pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;StudentsList&gt;
&lt;Student&gt;
&lt;student_id email="test@yahoo.com"&gt;18700&lt;/student_id&gt;
&lt;firstName&gt;Jhon&lt;/firstName&gt;
&lt;lastName&gt;Smith&lt;/lastName&gt;
&lt;address&gt;Dragon Vally china&lt;/address&gt;
&lt;/Student&gt;
&lt;Student&gt;
&lt;student_id email="LeeSin@gmail.com"&gt;18701&lt;/student_id&gt;
&lt;firstName&gt;Lee&lt;/firstName&gt;
&lt;lastName&gt;Sin&lt;/lastName&gt;
&lt;address&gt;League Of Legend UK&lt;/address&gt;
&lt;/Student&gt;
&lt;/StudentsList&gt;
</code></pre>

<p>when i search that file using xpath in php like </p>

<pre><code>$allStudents = $xml-&gt;xpath("//StudentsList/Student");
</code></pre>

<p>it give me all the students in an array with their child node and values like below:</p>

<pre><code>Array ( [0] =&gt; SimpleXMLElement Object ( [student_id] =&gt; 18700 [firstName] =&gt; Jhon [lastName] =&gt; Smith [address] =&gt; Dragon Vally china ) [1] =&gt; SimpleXMLElement Object ( [student_id] =&gt; 18701 [firstName] =&gt; Lee [lastName] =&gt; Sin [address] =&gt; League Of Legend UK ) [2] =&gt; SimpleXMLElement Object ( [student_id] =&gt; 18702 [firstName] =&gt; Xin [lastName] =&gt; Xaho [address] =&gt; Shanghi China ) [3] =&gt; SimpleXMLElement Object ( [student_id] =&gt; 18703 [firstName] =&gt; corki [lastName] =&gt; adc [address] =&gt; flying machine gun china ) [4] =&gt; SimpleXMLElement Object ( [student_id] =&gt; 18704 [firstName] =&gt; Kog [lastName] =&gt; Maw [address] =&gt; Depth of The Hell ) )
</code></pre>

<p>but as i have an attribute to student_id node i also want to get the value of that attribute too can any one please suggest what to do for that i google a lot but didn't find right answer. they gave examples for selecting parent by its attribute value but atleast i didn't find the one who select it with the whole node of student.</p>