I have an array like this, i am getting it by SQL query
Array
(
[0] => Array
(
[iId] => 1
[sName] => Tom
)
[1] => Array
(
[iId] => 2
[sName] => Jhon
)
)
then by this array, i am creating POST request, and getting XML Object back
SimpleXMLElement Object
(
[@attributes] => Array
(
[method] => userstats_xml
[version] => 2.0
)
[userstats] => SimpleXMLElement Object
(
[type] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 2
)
[test] => SimpleXMLElement Object
(
[output] => 1280
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 1
)
[test] => SimpleXMLElement Object
(
[output] => 6112
)
)
)
)
)
And now i am trying to get array like listed below, because i can output data from first array and xml object separately, but i need to do it in one line, for example
<a href="sId">sName - volume</a>
In array form:
Array
(
[0] => Array
(
[iId] => 1
[sName] => Tom
[volume] => 6112
)
[1] => Array
(
[iId] => 2
[sName] => Jhon
[volume] => 1280
)
)
Iterate over the array and use the ID to query the XML with XPath to get the “output” value
The code will take each ID in your array and construct an XPath query from it. The query finds all output elements in the document which are children of a test element which has to be a child of a type element with the ID attribute from your SQL array. If a result is found, the value of the output element is added to the SQL array at the currently iterated position.
See http://schlitt.info/opensource/blog/0704_xpath.html for a good XPath tutorial.