Accessing XML / REST web service

Hi guys,

I wish to access data of an XML as below:




<CraftyResponse>

<address_data_formatted>

<delivery_point>

<organisation_name/>

<department_name/>

<line_1>1 TREMELO GREEN</line_1>

<line_2/><line_3/>

<udprn>51985821</udprn>

</delivery_point>


<delivery_point>

<organisation_name/>

<department_name/>

<line_1>2 TREMELO GREEN</line_1>

<line_2/><line_3/>

<udprn>51985822</udprn>

</delivery_point>


<delivery_point_count>29</delivery_point_count>

<town>DAGENHAM</town>

<postal_county/>

<traditional_county>ESSEX</traditional_county>

<postcode>RM8 1DL</postcode>

</address_data_formatted>

</CraftyResponse>



How can get this data into arrays so I can pass that on to the form. Here is the URL of the web service:

http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode=rm81dl&response=data_formatted&lines=3&key=d476d-d308a-f12d9-00427

Awaiting response from Yii world.

Regards

To be able to help we will need more info.

The provided link - is that a yii based site?

Right now, based on your link, I am assuming you want to access a web sevice via REST from another site. As you may already know, there are now WSDL for REST and neither is there a common interface. I would suggest straight up php SimpleXML to interact with the XML?

The key thing here is that you would have to work with the structure of the xml document.





$uri = '[url="http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode=rm81dl&response=data_formatted&lines=3&key=d476d-d308a-f12d9-00427"]http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode=rm81dl&response=data_formatted&lines=3&key=d476d-d308a-f12d9-00427[/url]';

$crafty = new SimpleXMLElement($uri, NULL, true);

$array = $crafty->xpath(/xpath/query/to/access/node);


foreach ($array as $delivery)

{

   	// do what you gotta do here

}



or you could pass array to render()