I am sending some user data to an API which in return sends me a response in XML format. I use CURL to send the data.
However, I also see this header information:Code:- <response> <sm>OK</sm> <lid>16819301</lid> <ldaid>1185459</ldaid> <nb>4</nb> <amt>100.75</amt> - <buyer> <bn>Buyer 1</bn> <id>-1</id> <lu>/images/ilitest/lp_test_1.gif</lu> <lp>http://www.example.org/buyer1</lp> <dsc>Test description for company 1</dsc> <ph>800-555-0111</ph> <em>buyer1@example.org</em> </buyer> - <buyer> <bn>Buyer 2</bn> <id>-1</id> <lu>/images/ilitest/lp_test_2.gif</lu> <lp>http://www.example.org/buyer2</lp> <dsc>Test description for company 2</dsc> <ph>800-555-0122</ph> <em>buyer2@example.org</em> </buyer> - <buyer> <bn>Buyer 3</bn> <id>-1</id> <lu>/images/ilitest/lp_test_3.gif</lu> <lp>http://www.example.org/buyer3</lp> <dsc>Test description for company 3</dsc> <ph>800-555-0133</ph> <em>buyer3@example.org</em> </buyer> - <buyer> <bn>Buyer 4</bn> <id>-1</id> <lu>/images/ilitest/lp_test_4.gif</lu> <lp>http://www.example.org/buyer4</lp> <dsc>Test description for company 4</dsc> <ph>800-555-0144</ph> <em>buyer4@example.org</em> </buyer> <sid /> <cid /> <mid /> <tid /> </response>
Now my problem is to parse the XML properly and then to display just the information about the 4 different buyers if the status is "OK" (or to display an error page if the status is not Ok.Code:string(1334) "HTTP/1.1 200 OK Server: Resin/3.0.23 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT" Pragma: no-cache Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache Cache-Control: no-store Set-Cookie: JSESSIONID=abcoBg_CUGPxcbPTo1_bs; path=/ Content-Type: text/xml Transfer-Encoding: chunked Date: Tue, 07 Apr 2009 04:27:44 GMT
I spent the last 3 hours trying different code samples from many different websites, but this thing will just not work. Now I am completely drawing blank and need some advice on how to tackle this one and which way to go.
Thanks.




) , not generic XML data like your sample file. Better to use SimpleXML for that.

Bookmarks