I need some help on this one;
I need to parse my SOAP result into several PHP Arrays.
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<i2:GetDataResponse id="ref-1" xmlns:i2="http://schemas.microsoft.com/clr/nsassem/Teleperformance.Statistics.Webservice.DataService/CTIStatServer">
<return href="#ref-4"/>
</i2:GetDataResponse>
<i3:Data id="ref-4" xmlns:i3="http://www.twenty4help.com/ps/dataservice.wsdl">
<Values href="#ref-5"/>
</i3:Data>
<SOAP-ENC:Array id="ref-5" SOAP-ENC:arrayType="xsd:anyType[][13]">
<item href="#ref-6"/>
<item href="#ref-7"/>
<item href="#ref-8"/>
<item href="#ref-9"/>
<item href="#ref-10"/>
<item href="#ref-11"/>
<item href="#ref-12"/>
<item href="#ref-13"/>
<item href="#ref-14"/>
<item href="#ref-15"/>
<item href="#ref-16"/>
<item href="#ref-17"/>
<item href="#ref-18"/>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-6" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-7" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">64</item>
<item xsi:type="xsd:long">58</item>
<item xsi:type="xsd:long">576</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-8" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">21</item>
<item xsi:type="xsd:long">19</item>
<item xsi:type="xsd:long">140</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-9" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">36</item>
<item xsi:type="xsd:long">34</item>
<item xsi:type="xsd:long">49</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-10" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-11" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-12" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-13" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">51</item>
<item xsi:type="xsd:long">49</item>
<item xsi:type="xsd:long">70</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-14" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-15" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">10</item>
<item xsi:type="xsd:long">10</item>
<item xsi:type="xsd:long">13</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-16" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-17" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">5</item>
<item xsi:type="xsd:long">5</item>
<item xsi:type="xsd:long">8</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
<SOAP-ENC:Array id="ref-18" SOAP-ENC:arrayType="xsd:anyType[5]">
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
<item xsi:type="xsd:long">0</item>
</SOAP-ENC:Array>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I would need ref-6 till ref-18 in seperate PHP arrays as every ref from ref-6 on is a phone Queue with the call data in it. SO in this case I would expect 13 PHP arrays like $Queue1, $Queue2, etc. SO I can use the Arrays in my webscipt to display amount of calls per queue like
<?php echo $Queue2[2] ?> //answer would be 140 as ref-8 has value 140 at place 3
Please don't give me a lecture as I am only a Callcenter Supervisor with some scripting skills. So I am actually a noob :)
I got this far:
For testing purposes I use a local file xml1.xml where the soap output is stored. So $xml will be $result in the final code.
<?php
if (file_exists('xml1.xml')) {
$xml = simplexml_load_file('xml1.xml');
} else {
exit('Failed to open xml1.xml.');
}
$xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
foreach ($xml->xpath('//SOAP-ENC:Array') as $item)
{
//creaate array code should be here, but do know how to do it.
print_r ($item);
}
?>
Thank you for teaching me a lesson :) and helping me with this.