dimanche 28 juin 2015

How can I parse a complex XML with PHP and CDATA [on hold]

Hello I have the xml that i have attached. I need to parse it with php

  1. Get the hotel details in area name that i get from the URL for example XX.com/london.

I will get the london name and the hotel details in array(there is lot of hotels) or something else.

  1. some of the data is in CDATA - how can I parse it ?

How can I do those issues in PHP ?


<?xml version="1.0" encoding="UTF-8"?>
<root>
        <description>
                <![CDATA[Hotels list]]>
        </description>
                                <area>
                                        <name>London</name>
                                                                <hotel>
                                        <name>hotel1</name>
                                        <hotel_desc>
                                                <![CDATA[]]>
                                        </hotel_desc>
                                        <hotel_picture>
                                                <![CDATA[pic1]]>
                                        </hotel_picture>
                                        <stars>
                                                <![CDATA[4]]>
                                        </stars>                                  
                                </hotel>
                                                        <hotel>
                                        <name>hotel2</name>
                                        <hotel_desc>
                                                <![CDATA[desc
]]>
                                        </hotel_desc>
                                        <hotel_picture>
                                                <![CDATA[pic.jpg]]>
                                        </hotel_picture>
                                        <stars>
                                                <![CDATA[5]]>
                                        </stars>                                  
                                </hotel>
</area>
</root>

Aucun commentaire:

Enregistrer un commentaire