Я сохранил ответ Xml в сеансе?Теперь, как показать значения XML на веб-странице, используя php? - PullRequest
0 голосов
/ 08 июля 2011

Я работаю над локонами.Я сохранил ответ xml curl в сеансе.Теперь, как я могу представить значения XML на веб-странице?Сколько способов мы можем решить эту задачу?

Это мой xml ответ.

  <?xml version="1.0" encoding="UTF-8"?>
    <OTA_HotelAvailRS Version="1.0">
      <Success Id="141575"/>
      <Properties>

        <Property HotelCityCode="ELS" HotelCode="13553" HotelName="Premier Hotel Regent - Demo">
        <RelativePosition Direction="" Distance="0" DistanceUnitName=""/>
        <EssentialInfo>

        </EssentialInfo>
        <RoomStays>


            <RoomStay>
                <RatePlans>
                    <RatePlan RatePlanCode="35771"/>
                </RatePlans>
                <RoomRates>
                    <RoomRate>
                        <Rates>
                            <Rate EffectiveDate="2011-10-14" ExpireDate="2011-10-15">
                                <Base Amount="114.00" CurrencyCode="EUR"/>

                                <RateDescription Adults="1" Availability="A" Children="0" RoomNum="1">
                                    Standard
                                </RateDescription>
                            </Rate>
                        </Rates>
                    </RoomRate>
                </RoomRates>

                <Meals Description="Breakfast Buffet" MealType="Breakfast"/>

            </RoomStay>


        </RoomStays>
        <Promotions/>

        <AdditionalInfo>
            <HotelStarDetail rating="3"/>

            <HotelImages>

                <HotelImage Type="" URL="http://image1.urlforimages.com/1204258/Premier-Hotel-Regent_guest.jpg"/>

            </HotelImages>

            <HotelDescription>
                <LongDescription> General Description: Beachfront accommodations Location: Conveniently located in the river port city of East London  Located close to shopping area  Perfectly located in beautiful Esplanade overlooking the Indian Ocean Local Attractions: Close to local attractions such as John Gately House, The Hood Point Lighthouse, East London Museum  Nearby outdoor sport activities  Restaurants &amp;amp;&amp;#186;  Lounges: Onsite restaurant Services: 24 hr front desk service  Room service  Valet dry cleaning and laundry services  Shuttle service is available  Meeting Facilities:  Conference rooms hosting up to 800 people  Convention facilities   Small conference room available  Event facilities   Fully equipped business center  Accommodation: Luxury guest rooms  175 guestrooms</LongDescription>

            </HotelDescription>
        </AdditionalInfo>

    </Property>

    <Property HotelCityCode="ELS" HotelCode="13552" HotelName="Mpongo Private Game Reserve - Demo">
        <RelativePosition Direction="" Distance="0" DistanceUnitName=""/>
        <EssentialInfo>

        </EssentialInfo>
        <RoomStays>

            <RoomStay>

                <RatePlans>
                    <RatePlan RatePlanCode="35769"/>
                </RatePlans>
                <RoomRates>
                    <RoomRate>
                        <Rates>
                            <Rate EffectiveDate="2011-10-14" ExpireDate="2011-10-15">
                                <Base Amount="117.00" CurrencyCode="EUR"/>
                                <RateDescription Adults="1" Availability="A" Children="0" RoomNum="1">

                                    Standard
                                </RateDescription>
                            </Rate>
                        </Rates>
                    </RoomRate>
                </RoomRates>

                <Meals Description="Half board" MealType="HalfBoard"/>

            </RoomStay>

            <RoomStay>

                <RatePlans>
                    <RatePlan RatePlanCode="35770"/>
                </RatePlans>
                <RoomRates>
                    <RoomRate>
                        <Rates>
                            <Rate EffectiveDate="2011-10-14" ExpireDate="2011-10-15">
                                <Base Amount="174.00" CurrencyCode="EUR"/>
                                <RateDescription Adults="1" Availability="A" Children="0" RoomNum="1">

                                    River Lodge
                                </RateDescription>
                            </Rate>
                        </Rates>
                    </RoomRate>
                </RoomRates>

                <Meals Description="Half board" MealType="HalfBoard"/>

            </RoomStay>

        </RoomStays>

        <Promotions/>

        <AdditionalInfo>
            <HotelStarDetail rating="4"/>

            <HotelImages>

                <HotelImage Type="" URL="http://image1.urlforimages.com/1204253/Mpongo-Private_guest.jpg"/>

            </HotelImages>

            <HotelDescription>
                <LongDescription> General Description: Close proximity to major attractions Location: Located in the heart of Eastern Cape at Mpongo  Shopping area is just minutes away Local Attractions: Nearby outdoor sport activities   Close to local attractions such as 2 ? to 3 hour open vehicle game drive, bringing them close to lions, impala, zebra, giraffes, elephants and several smaller animal species Recreation: Outdoor swimming pool Restaurants &amp;amp;&amp;#186;  Lounges: Onsite restaurant Services: Valet dry cleaning and laundry services Meeting Facilities:  Banquet facilities   Wedding venue available Accommodation: 18 guestrooms</LongDescription>

            </HotelDescription>
        </AdditionalInfo>

    </Property>

    <Property HotelCityCode="ELS" HotelCode="13551" HotelName="GARDEN COURT EAST LONDON">
        <RelativePosition Direction="" Distance="" DistanceUnitName=""/>
        <EssentialInfo>

        </EssentialInfo>
        <RoomStays>

            <RoomStay>

                <RatePlans>
                    <RatePlan RatePlanCode="35767"/>
                </RatePlans>
                <RoomRates>
                    <RoomRate>
                        <Rates>
                            <Rate EffectiveDate="2011-10-14" ExpireDate="2011-10-15">
                                <Base Amount="162.00" CurrencyCode="EUR"/>
                                <RateDescription Adults="1" Availability="R" Children="0" RoomNum="1">

                                    Twin for sole use (Standard)
                                </RateDescription>
                            </Rate>
                        </Rates>
                    </RoomRate>
                </RoomRates>

                <Meals Description="Full breakfast" MealType="Breakfast"/>

            </RoomStay>

            <RoomStay>

                <RatePlans>
                    <RatePlan RatePlanCode="35768"/>
                </RatePlans>
                <RoomRates>
                    <RoomRate>
                        <Rates>
                            <Rate EffectiveDate="2011-10-14" ExpireDate="2011-10-15">
                                <Base Amount="162.00" CurrencyCode="EUR"/>
                                <RateDescription Adults="1" Availability="R" Children="0" RoomNum="1">

                                    Single (Standard)
                                </RateDescription>
                            </Rate>
                        </Rates>
                    </RoomRate>
                </RoomRates>

                <Meals Description="Full breakfast" MealType="Breakfast"/>

            </RoomStay>

        </RoomStays>

        <Promotions/>

        <AdditionalInfo>
            <HotelStarDetail rating="3"/>

            <HotelFacilities>

                <Facility Code="*AC" Description="Air conditioning" Name="RoomFacility"/>

                <Facility Code="*EC" Description="Earliest check-in at 12:00" Name="HotelFacility"/>

                <Facility Code="*GY" Description="Gymnasium" Name="HotelFacility"/>

                <Facility Code="*HD" Description="Hairdryer" Name="RoomFacility"/>

                <Facility Code="*OP" Description="1 outdoor pool (heated)" Name="HotelFacility"/>


                <Facility Code="*RS" Description="Room Service from  8:00 to 23:30" Name="HotelFacility"/>

                <Facility Code="*TV" Description="Television" Name="RoomFacility"/>

            </HotelFacilities>

            <HotelImages>

                <HotelImage Type="Bar/Lounge" URL="http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-11.jpg"/>

                <HotelImage Type="Lobby" URL="http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-8.jpg"/>

                <HotelImage Type="Exterior" URL="http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-1.jpg"/>

                <HotelImage Type="Recreational Facilities" URL="http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-12.jpg"/>

                <HotelImage Type="Guest Room" URL="http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-9.jpg"/>


                <HotelImage Type="Restaurant" URL="http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-10.jpg"/>

                <HotelImage Type="Swimming Pool" URL="http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-3.jpg"/>

            </HotelImages>

            <HotelDescription>
                <LongDescription>&lt;b&gt;LOCATION&lt;/b&gt;&lt;br&gt;Located on the city's Eastern Beach Promenade the hotel is 20kms from East London airport.  For holidaymakers, the beach is in close proximity and several landmarks and attractions are also not far away from the Garden Court East London such as the Aquarium and the popular Whale Watchers Deck, the famous Nahoon Beach and Gately House museum.&lt;br&gt;&lt;br&gt;&lt;b&gt;ROOMS&lt;/b&gt;&lt;br&gt;The 173 rooms  are slick and modern in design with good size comfortable beds.  All are en suite and offer remote controlled TV and a host of satellite channels, in ,room dining service between 18h30 and 22h00 daily and individually controlled air conditioning all part of the facilities to make you feel welcome and relaxed. Smoking and wheelchair accessible rooms are available on request.&lt;br&gt;&lt;br&gt;&lt;b&gt;RESTAURANT&lt;/b&gt;&lt;br&gt;The Ubuntu restaurant at Garden Court East London offers a buffet breakfast daily, as well as a carvery buffet every evening.  The Brassiere offers a coffee shop menu with light meals.&lt;br&gt;&lt;br&gt;&lt;b&gt;EXTERIOR&lt;/b&gt;&lt;br&gt;A six storey modern building with balconies dominating the facade.&lt;br&gt;&lt;br&gt;&lt;b&gt;LOBBY&lt;/b&gt;&lt;br&gt;A welcoming entrance with seating area for guests and a reception desk&lt;br&gt;&lt;br&gt;&lt;b&gt;GENERAL&lt;/b&gt;&lt;br&gt;The hotel has excellent conferencing facilities as well as a business centre and there is Wifi available for a fee in all rooms as well as public areas.
                There is also a small gym which is free for guests to use as well as a big outdoor swimming pool with sun loungers.&lt;br&gt;&lt;br&gt;</LongDescription>
            </HotelDescription>
        </AdditionalInfo>
    </Property>
</Properties>

Ответы [ 2 ]

0 голосов
/ 08 июля 2011

В PHP есть много способов чтения XML, и вот полный обзор XML Manipulation . Самым простым и простым является simplexml и, возможно, DOMDocument , что немного сложнее. Если вам просто нужно прочитать XML-файлы, вы также можете посмотреть на XMLReader.

Если вы хотите распечатать документ как есть, вы должны использовать htmlentities ($ xmlString);

0 голосов
/ 08 июля 2011

анализ строки xml, итерация по узлам и распечатка вашего HTML.

...