 <p>If the XML you're trying to parse is what you've posted here, it's invalid since </p> <blockquote> <p>XML documents must contain one root element that is the parent of all other elements:</p> </blockquote> <p><a href="http://www.w3schools.com/xml/xml_syntax.asp" rel="nofollow">http://www.w3schools.com/xml/xml_syntax.asp</a></p> <p>(and yours doesn't, and parsing such string fails with <code>Exception: String could not be parsed as XML in ...</code>).</p> <p>So your XML should be:</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>And you don't need to iterate through the collection</p> <pre><code>// $nodes is SimpleXMLElement $user = $nodes-&gt;user[0]; if($user-&gt;token) return $user-&gt;token-&gt;__toString(); </code></pre>