Wie konvertiert curl xml-Antwort in ein array in php?
Ich bin mit curl in mein Projekt. Wenn ich die Anfrage senden, die Antwort kommt in form von XML-als Gebrüll. Wie konvertiere ich dieses xml in ein array zu präsentieren, in der web-Seite.
<?xml version="1.0" encoding="UTF-8"?>
<OTA_HotelAvailRS Version="1.0">
<Success Id="140948"/>
<Properties>
<Property HotelCityCode="ELS" HotelCode="18918" HotelName="Premier Hotel Regent - Demo">
<RelativePosition Direction="" Distance="0" DistanceUnitName=""/>
<EssentialInfo>
</EssentialInfo>
<RoomStays>
<RoomStay>
<RatePlans>
<RatePlan RatePlanCode="50010"/>
</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/1204258guest.jpg"/>
</HotelImages>
<HotelDescription>
<LongDescription> description</LongDescription>
</HotelDescription>
</AdditionalInfo>
</Property>
</Properties>
- Welche Sprache?
- In PHP ...............
Du musst angemeldet sein, um einen Kommentar abzugeben.
Warum wandeln Sie es in ein array überhaupt? PHP ist Recht gut mit XML. Laden Sie einfach die XML in SimpleXML oder eine DOMDocument und verwenden Sie es direkt.
foreach
über eine XML-Baum verklagt SimpleXML. Siehe Beispiel #4 auf nl.php.net/manual/en/simplexml.examples-basic.php