I have the following string and I want to parse username and password from this string ...
$xmlstring='<soap-env:envelope xmlns:ns1="http://back.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:header></soap-env:header>
<soap-env:body>
<ns1:createuserresponse>
<username>qqq_d481</username>
<password>sdfdssdfds</password>
<result>
<succeeded>true</succeeded>
<errorcode>0</errorcode>
<errortext></errortext>
</result>
</ns1:createuserresponse>
</soap-env:body>
</soap-env:envelope>';
Please suggest.
above string is SOAP response
but if I use:
$xmlstring='<soap-env:envelope>
<soap-env:header></soap-env:header>
<soap-env:body>
<ns1:createuserresponse>
<username>qqq_d481</username>
<password>sdfdssdfds</password>
<result>
<succeeded>true</succeeded>
<errorcode>0</errorcode>
<errortext></errortext>
</result>
</ns1:createuserresponse>
</soap-env:body></soap-env:envelope>';
echo $xmltoparse= $xmlstring;
$xml = simplexml_load_string($xmltoparse);
print_r($xml);
then it works fine