Get specific node in xml?
<p>my xml is structured as follow:</p>

<pre><code>&lt;?xml version="1.0" ?&gt;
&lt;users&gt;
    &lt;user&gt;
        &lt;name&gt;
            foo
        &lt;/name&gt;
        &lt;token&gt;
            jfhsjfhksdjfhsjkfhksjfsdk
        &lt;/token&gt;
        &lt;connection&gt;
            &lt;host&gt;
                localhost
            &lt;/host&gt;
            &lt;username&gt;
                root
            &lt;/username&gt;
            &lt;dbName&gt;
                Test
            &lt;/dbName&gt;
            &lt;dbPass&gt;
                123456789
            &lt;/dbPass&gt;
        &lt;/connection&gt;
    &lt;/user&gt;
    &lt;user&gt;
        ... same structure...
    &lt;/user&gt;
&lt;/users&gt;
</code></pre>

<p>I made this code that iterate through all xml node:</p>

<pre><code>function getConString($node)
{
   $item = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "con");
   $nodes = new SimpleXMLElement($item);
   $result = $nodes[0];

   foreach($result as $item =&gt; $value)
   {
      if($item == "token")
      {
         return $value-&gt;__toString();
     }
   }
}
</code></pre>

<p>what I'm trying to achieve is that when $node is equal to:</p>

<pre><code>jfhsjfhksdjfhsjkfhksjfsdk
</code></pre>

<p>the connection node is returned as array, how I can achieve this?</p>

<p><strong>UPDATE:</strong></p>

<p>For someone that doesn't have understood, simply I want that if I insert the token: <code>jfhsjfhksdjfhsjkfhksjfsdk</code> the connection of the user with the token <code>jfhsjfhksdjfhsjkfhksjfsdk</code> will be returned. So in this case I want get all the content of <code>connection</code> node and create a connection string:</p>

<pre><code>&lt;connection&gt;
            &lt;host&gt;
                localhost
            &lt;/host&gt;
            &lt;username&gt;
                root
            &lt;/username&gt;
            &lt;dbName&gt;
                Test
            &lt;/dbName&gt;
            &lt;dbPass&gt;
                123456789
            &lt;/dbPass&gt;
        &lt;/connection&gt;
</code></pre>