title: getting element values from an xml soap response when there is double xml tag
body: <p>I HAVE THIS XML RESPONSE FROM A SOAP CALL:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;loginResponse xmlns="http://wws.adomain.com/"&gt;&lt;loginResult&gt;&lt;xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;&lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="replay" msdata:UseCurrentLocale="true"&gt;&lt;xs:complexType&gt;&lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;&lt;xs:element name="replay"&gt;&lt;xs:complexType&gt;&lt;xs:sequence&gt;&lt;xs:element name="code" type="xs:string" minOccurs="0" /&gt;&lt;xs:element name="description" type="xs:string" minOccurs="0" /&gt;&lt;/xs:sequence&gt;&lt;/xs:complexType&gt;&lt;/xs:element&gt;&lt;/xs:choice&gt;&lt;/xs:complexType&gt;&lt;/xs:element&gt;&lt;/xs:schema&gt;&lt;diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&gt;&lt;DocumentElement xmlns=""&gt;&lt;replay diffgr:id="replay1" msdata:rowOrder="0" diffgr:hasChanges="inserted"&gt;&lt;code&gt;OK&lt;/code&gt;&lt;description&gt;
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;root&gt;&lt;token&gt;e6d354f2-b284569e20-b2def8f3ef4a&lt;/token&gt;&lt;nmDealer&gt;SAP001 NAME&lt;/nmDealer&gt;&lt;idRegDealer&gt;8763&lt;/idRegDealer&gt;&lt;idRegGrupo&gt;-1&lt;/idRegGrupo&gt;&lt;idRegPuntoVenta&gt;-1&lt;/idRegPuntoVenta&gt;&lt;idRegUsuario&gt;35350731&lt;/idRegUsuario&gt;&lt;idRegVendedor&gt;-1&lt;/idRegVendedor&gt;&lt;idRegZona&gt;-1&lt;/idRegZona&gt;&lt;dsTpUsuario&gt;CLIENTES&lt;/dsTpUsuario&gt;&lt;dsPais&gt;PRODUCCION&lt;/dsPais&gt;&lt;idioma&gt;EN&lt;/idioma&gt;&lt;idRegIdioma&gt;9&lt;/idRegIdioma&gt;&lt;isImputar&gt;False&lt;/isImputar&gt;&lt;moneda&gt;€&lt;/moneda&gt;&lt;tpUsuario&gt;1&lt;/tpUsuario&gt;&lt;idRegComisionVariableDealer&gt;-1&lt;/idRegComisionVariableDealer&gt;&lt;permitirComisionVariableDealer&gt;1&lt;/permitirComisionVariableDealer&gt;&lt;firstAccess&gt;0&lt;/firstAccess&gt;&lt;acceptedConditions&gt;False&lt;/acceptedConditions&gt;&lt;idRegInsured&gt;-1&lt;/idRegInsured&gt;&lt;idRegAuditor&gt;-1&lt;/idRegAuditor&gt;&lt;/root&gt;&lt;/description&gt;&lt;/replay&gt;&lt;/DocumentElement&gt;&lt;/diffgr:diffgram&gt;&lt;/loginResult&gt;&lt;/loginResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;
  </code></pre>
  
  <p><a href="http://prntscr.com/9cfdwk" rel="nofollow">http://prntscr.com/9cfdwk</a></p>
  
  <hr>
  
  <p>I want to be able to get the values of element (eg token) in the second xml tag (<code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code>) Any prompt assistance will be appreciated.</p>
  
  <p>HERE IS MY CODE:</p>
  
  <pre><code>$s = new soapclientw($wsdlfile);
  if (empty($proxyhost))
  {
  
  }
  else{
      $s-&gt;setHTTPProxy($proxyhost,$proxyport,$proxyusr,$proxypassword);
  }
  $result = $s-&gt;send($msg,'http://wws.domain.com/login',60);
  
  $myXMLData = $s-&gt;responseData;
  
  libxml_use_internal_errors(true);
  
  $xml = simplexml_load_string($myXMLData);
  
  if ($xml === false) {
      echo "Failed loading XML: ";
      foreach(libxml_get_errors() as $error) {
          echo "&lt;br&gt;", $error-&gt;message;
      }
  } 
  else{
      echo $xml-&gt;token;
  }
  </code></pre>