PHP: Returning XML in SOAP function call
I want to return the following XML in SOAP when a function is called rather than just a string. There are many different functions that will return an xml formatted this way, is there a way that I can define what a function returns? Like making my own data type?
<meta>
<supplier>Amazon.com</supplier>
<datetime>2010/08/21 14:32:40</datetime>
</meta>
<results>
<result>
<manufacturer>Intel</manufacturer>
<itemno>8236476234</itemno>
<开发者_Go百科prices>
<price>
<quantity>10</quantity>
<cost>$1.20</cost>
</price>
<price>
<quantity>100</quantity>
<cost>$0.80</cost>
</price>
</prices>
</result>
<result> ... </result>
</results>
The best way is to put your result in an array
and then convert it to XML
. Here is a ready made script for that:
http://rssphp.net/examples/convert_array_to_xml/
It converts almost any kind of associative array to full formed XML.
精彩评论