/** * Attempt to parse */ public function testParseXML() { $xml = <<<EOF <?xml version="1.0"?> <user_info> <total_users>3</total_users> <users> <item0> <id>1</id> <name>Nitya</name> <address> <country>India</country> <city>Kolkata</city> <zip>700102</zip> </address> </item0> <item1> <id>2</id> <name>John</name> <address> <country>USA</country> <city>Newyork</city> <zip>NY1234</zip> </address> </item1> <item2> <id>3</id> <name>Viktor</name> <address> <country>Australia</country> <city>Sydney</city> <zip>123456</zip> </address> </item2> </users> </user_info> EOF; $parsed = Parser::parse($xml); $this->assertNotEmpty($parsed); $this->assertArrayHasKey('total_users', $parsed); }
/** * Process returned xml body * @return object self */ public function process() { $data = Parser::parse((string) $this->_response->getBody()); $root = $data[$this->getXmlRootNode()]; $this->setBody($data); if ($root['Result']['Code'] > 0) { $this->setErrorCode($root['Result']['Code']); $this->setErrorType($root['Result']['Type']); $this->setErrorMessage($root['Result']['Description']); } else { // Set reponse data // fix casting of false as string since they send out 'false' for // missing information or invalid information if ($root['ResponseData'] == 'false') { $root['ResponseData'] = false; } $this->setResult($root['ResponseData']); } return $this; }