我对此很陌生,发现的解决方案非常笼统,没有示例。任何帮助将不胜感激。我目前正在使用此代码提取xml响应。
$response = simplexml_load_string($data);
$json = json_encode($response);
$arr = json_decode($json,true);
print_r($arr);
我从打印功能获取的数据是:
Array ([@attributes] => Array([TimeStamp] => 2019-06-07T13:29:31+02:00[Version] => 1.006[PrimaryLangID] => en[EchoToken] => HL[Target] => Test)[Success] => Array()[Properties] => Array([Property] => Array([0] => Array([@attributes] => Array([HotelCode] => 12123[HotelCityCode] => 412[HotelName] => Embassy Hotel[HotelCodeContext] => HCL[HotelSegmentCategoryCode] => 14)[VendorMessages] => Array([VendorMessage] => Array([@attributes] => Array([InfoType] => 1[Language] => en[Title] => Description)[SubSection] => Array([Paragraph] => Array([Text] => Array([@attributes] => Array([Language] => en))))))[Position] => Array([@attributes] => Array([Latitude] => 33.895978124710595[Longitude] => 35.485711097717285))[Address] => Array([AddressLine] => Makdessi Street - facing LibanPost, Hamra - Beirut[CityName] => Beirut[CountryName] => Lebanon)[Amenities] => Array([Amenity] => Array([0] => TV[1] => Fridge[2] => Phone[3] => Air conditioning[4] => Heating[5] => Lift / elevator[6] => Room service[7] => Internet access[8] => Laundry Service[9] => Cable/Satellite TV[10] => Hairdryer))[RateRange] => Array([@attributes] => Array([MinRate] => 35.80[MaxRate] =>[CurrencyCode] => EUR))[TPA_Extensions] => Array([ThumbPicture] => Array([@attributes] => Array([Url] => www.hostelspoint.com/pics/12123/th-012123-1226047198.jpg))[FullSizePicture] => Array([@attributes] => Array([Url] => www.hostelspoint.com/pics/12123/012123-1226047198.jpg))[CustomerRatings] => Array([Rating] => Array([0] => Array([@attributes] => Array([Type] => overall[Value] => 80[NumberRatings] => 2[Base] => 100[Description] => overall rating))[1] => Array([@attributes] => Array([Type] => cleanliness[Value] => 80[Base] => 100[Description] => cleanliness))[2] => Array([@attributes] => Array([Type] => staff[Value] => 70[Base] => 100[Description] => staff))[3] => Array([@attributes] => Array([Type] => position[Value] => 90[Base] => 100[Description] => location))[4] => Array([@attributes] => Array([Type] => fun_factor[Value] => 80[Base] => 100[Description] => value))[5] => Array([@attributes] => Array([Type] => personality[Value] => 80[Base] => 100[Description] => recommended))))[HotelCategory] => Array([@attributes] => Array([Code] => 20))[TextCategory] => Hotel ***))[1] => Array([@attributes] => Array([HotelCode] => 38888[HotelCityCode] => 412[HotelName] => LOFT 29 Residence[HotelCodeContext] => HCL[HotelSegmentCategoryCode] => 2)[VendorMessages] => Array([VendorMessage] => Array([@attributes] => Array([InfoType] => 1[Language] => en[Title] => Description)[SubSection] => Array([Paragraph] => Array([Text] => Array([@attributes] => Array([Language] => en))))))[Position] => Array([@attributes] => Array([Latitude] => 33.8952441[Longitude] => 35.48340840000003))[Address] => Array([AddressLine] => Omar Bin Abdul Aziz - Bayrut - Beirut - Beirut Governorate - Lebanon, 2034 1111 Beirut, Lebanon[CityName] => Beirut[CountryName] => Lebanon)[Amenities] => Array([Amenity] => Array([0] => TV[1] => Fridge[2] => Phone[3] => Air conditioning[4] => Heating[5] => Lift / elevator[6] => Internet access[7] => Laundry Service[8] => Cable/Satellite TV[9] => Security boxes / Lockers[10] => Pickups / Shuttle from airport[11] => Hairdryer))[RateRange] => Array([@attributes] => Array([MinRate] => 71.61[MaxRate] =>[CurrencyCode] => EUR))[TPA_Extensions] => Array([ThumbPicture] => Array([@attributes] => Array([Url] => www.hostelspoint.com/pics/38888/th-filepict-1553857468.jpg))[FullSizePicture] => Array([@attributes] => Array([Url] => www.hostelspoint.com/pics/38888/filepict-1553857468.jpg))[CustomerRatings] => Array([@attributes] => Array([NotRated] => true))[HotelCategory] => Array([@attributes] => Array([Code] => 3))[TextCategory] => Apartment)))) )
如何提取HotelCode的值以及如何提取要在HTML中使用的图片链接?