1

I am trying to parse the following SOAP using PHP. I have tried every possible solution found in here but I did not manage it due to the namespaces used. Can please someone help?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:geo="http://path.to.geo" xmlns:geo1="http://path/">
<soapenv:Header/>
<soapenv:Body>
  <geo:SendClient>
     <geo1:SendClientRequest>
        <geo1:GeneralInfo>
            <geo1:Team>AP</geo1:Team>
        </geo1:GeneralInfo>
     </geo1:SendClientRequest>
  </geo:SendClient>
</soapenv:Body>
</soapenv:Envelope>

I want to get the value AP in the Output.

$xmlData = simplexml_load_file('request.xml');
$xmlData->registerXPathNamespace('geo1', 'http://path/');
foreach ($xmlData->xpath('//geo1:GeneralInfo') as $item)
{
  print_r($item);
var_export($item->xpath('//geo1:Team'));
}

1 Answer 1

1

After spending hours I found out that the right way to print the output is:

$result = $item->xpath('//geo1:Team');
echo (string)$result[0];

instead of

var_export($item->xpath('//geo1:Team'));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.