ApaiIO\ResponseTransformer\XmlToArray::transform PHP Метод

transform() публичный Метод

public transform ( $response )
    public function transform($response)
    {
        $simpleXml = simplexml_load_string($response);
        $array = json_decode(json_encode($simpleXml), true);
        return $array;
    }

Usage Example

Пример #1
0
 public function testXmlToArray()
 {
     $transformer = new XmlToArray();
     $sampleXML = $this->getSampleXMLResponse();
     $array = $transformer->transform($sampleXML);
     $this->assertInternalType('array', $array);
     $this->assertEquals('Wikipedia Städteverzeichnis', $array['titel']);
     $this->assertEquals('Genf', $array['eintrag']['0']['stichwort']);
 }
XmlToArray