php soap响应数组

时间:2016-12-03 14:08:31

标签: soap xml-parsing soap-client

我正在使用租赁预订webservice并且它返回xml响应现在我必须使用php在我的站点中使用该响应。 对于xml,您可以查看此页面     https://www.jimpisoft.pt/Rentway_Internacional_Reservations_WS/getPriceQuote.asmx?op=PriceQuote


    $xml = simplexml_load_string($response);
    $json = json_encode($xml);
    $arr = json_decode($json,true);
    print_r($arr);

但是它说XML解析错误:语法错误 我也试过这个


    include 'xmlParser.class.php';
                                         $oXmlParser = new xmlParser();
                                         $asArray = $oXmlParser->xml2array($ssString);

                                         $asArray1 = $oXmlParser->xml2array($ssString,'');
                                         $asArray2 = $oXmlParser->xml2array($ssString,1,'');
                                         $response14 = preg_replace("/(]*>)/", "$1$2$3", $asArray);

                                         print_r($response14);

这是xml

<soap:Envelope><soap:Body><StationDetailsResponse><StationDetailsResult><stationDetails><xs:schema id="StationDetails"><xs:element name="StationDetails" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="Table"><xs:complexType><xs:sequence><xs:element name="StationID" type="xs:string" minOccurs="0"/><xs:element name="Station" type="xs:string" minOccurs="0"/><xs:element name="Zone" type="xs:int" minOccurs="0"/><xs:element name="StationType" type="xs:int" minOccurs="0"/><xs:element name="StationTypeDescription" type="xs:string" minOccurs="0"/><xs:element name="Address" type="xs:string" minOccurs="0"/><xs:element name="WeekDayOpen" type="xs:string" minOccurs="0"/><xs:element name="WeekdayLunchIni" type="xs:string" minOccurs="0"/><xs:element name="WeekdayLunchFim" type="xs:string" minOccurs="0"/><xs:element name="WeekDayClose" type="xs:string" minOccurs="0"/><xs:element name="SaturDayOpen" type="xs:string" minOccurs="0"/><xs:element name="SaturdayLunchIni" type="xs:string" minOccurs="0"/><xs:element name="SaturdayLunchFim" type="xs:string" minOccurs="0"/><xs:element name="SaturDayClose" type="xs:string" minOccurs="0"/><xs:element name="SunDayOpen" type="xs:string" minOccurs="0"/><xs:element name="SundayLunchIni" type="xs:string" minOccurs="0"/><xs:element name="SundayLunchFim" type="xs:string" minOccurs="0"/><xs:element name="SunDayClose" type="xs:string" minOccurs="0"/><xs:element name="HolidayOpen" type="xs:string" minOccurs="0"/><xs:element name="HolidayLunchIni" type="xs:string" minOccurs="0"/><xs:element name="HolidayLunchFim" type="xs:string" minOccurs="0"/><xs:element name="HolidayClose" type="xs:string" minOccurs="0"/><xs:element name="AfterHour_Enable" type="xs:boolean" minOccurs="0"/><xs:element name="AfterHour_Weekday" type="xs:string" minOccurs="0"/><xs:element name="AfterHour_Saturday" type="xs:string" minOccurs="0"/><xs:element name="AfterHour_Sunday" type="xs:string" minOccurs="0"/><xs:element name="AfterHour_Holiday" type="xs:string" minOccurs="0"/><xs:element name="AfterHours_CheckOut" type="xs:boolean" minOccurs="0"/><xs:element name="AfterHours_CheckIn" type="xs:boolean" minOccurs="0"/><xs:element name="AfterHour_Extra" type="xs:string" minOccurs="0"/><xs:element name="Address1" type="xs:string" minOccurs="0"/><xs:element name="Address2" type="xs:string" minOccurs="0"/><xs:element name="PostalCode" type="xs:string" minOccurs="0"/><xs:element name="City" type="xs:string" minOccurs="0"/><xs:element name="Country" type="xs:int" minOccurs="0"/><xs:element name="Phone1" type="xs:string" minOccurs="0"/><xs:element name="Phone2" type="xs:string" minOccurs="0"/><xs:element name="Fax" type="xs:string" minOccurs="0"/><xs:element name="Email" type="xs:string" minOccurs="0"/><xs:element name="Latitude" type="xs:decimal" minOccurs="0"/><xs:element name="Longitude" type="xs:decimal" minOccurs="0"/><xs:element name="ResponsibleName" type="xs:string" minOccurs="0"/><xs:element name="ResponsiblePhone" type="xs:string" minOccurs="0"/><xs:element name="CellPhone" type="xs:string" minOccurs="0"/><xs:element name="StationAddInfo" type="xs:string" minOccurs="0"/><xs:element name="StationAddInfo1" type="xs:string" minOccurs="0"/><xs:element name="IsFlightInfoMandatory" type="xs:boolean" minOccurs="0"/><xs:element name="AfterHour_Weekday_Start" type="xs:string" minOccurs="0"/><xs:element name="AfterHour_Saturday_Start" type="xs:string" minOccurs="0"/><xs:element name="AfterHour_Sunday_Start" type="xs:string" minOccurs="0"/><xs:element name="AfterHour_Holiday_Start" type="xs:string" minOccurs="0"/><xs:element name="StationHoliday" msdata:DataType="System.Data.DataTable, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:anyType" minOccurs="0"/><xs:element name="Schedule" msdata:DataType="System.Data.DataTable, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:anyType" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram><StationDetails><Table diffgr:id="Table1" msdata:rowOrder="0"><StationID>ARN</StationID><Station>Arlanda airport          </Station><Zone>9</Zone><StationType>2</StationType><StationTypeDescription>Airport</StationTypeDescription><Address>Elkraftsgatan 2  </Address><WeekDayOpen>00:00</WeekDayOpen><WeekdayLunchIni xml:space="preserve">     </WeekdayLunchIni><WeekdayLunchFim xml:space="preserve">     </WeekdayLunchFim><WeekDayClose>23:59</WeekDayClose><SaturDayOpen>00:00</SaturDayOpen><SaturdayLunchIni xml:space="preserve">     </SaturdayLunchIni><SaturdayLunchFim xml:space="preserve">     </SaturdayLunchFim><SaturDayClose>23:59</SaturDayClose><SunDayOpen>00:00</SunDayOpen><SundayLunchIni xml:space="preserve">     </SundayLunchIni><SundayLunchFim xml:space="preserve">     </SundayLunchFim><SunDayClose>23:59</SunDayClose><HolidayOpen>00:00</HolidayOpen><HolidayLunchIni xml:space="preserve">     </HolidayLunchIni><HolidayLunchFim xml:space="preserve">     </HolidayLunchFim><HolidayClose>23:59</HolidayClose><AfterHour_Enable>false</AfterHour_Enable><AfterHours_CheckOut>true</AfterHours_CheckOut><AfterHours_CheckIn>false</AfterHours_CheckIn><Address1>Elkraftsgatan 2</Address1><Address2/><PostalCode>195 60</PostalCode><City>Arlandastad</City><Country>203</Country><Phone1>+46 8 591 150 78</Phone1><Phone2>+46 8 591 150 55</Phone2><Fax/><Email>sweden@addcar.com</Email><Latitude>59.36550</Latitude><Longitude>17.53400</Longitude><ResponsibleName>Esa Palmborg</ResponsibleName><ResponsiblePhone>+46 8 591 150 78</ResponsiblePhone><CellPhone/><StationAddInfo>Please call +46 8 591 150 55 for pickup at your terminal, Go to bus stand 7 and wait for the "Flygplatsparkering/addCar" shuttle bus.</StationAddInfo><StationAddInfo1>Please call +46 8 591 150 55 for pickup at your terminal, Go to bus stand 7 and wait for the "Flygplatsparkering/addCar" shuttle bus.</StationAddInfo1><IsFlightInfoMandatory>false</IsFlightInfoMandatory><AfterHour_Weekday_Start xml:space="preserve">     </AfterHour_Weekday_Start><AfterHour_Saturday_Start xml:space="preserve">     </AfterHour_Saturday_Start><AfterHour_Sunday_Start xml:space="preserve">     </AfterHour_Sunday_Start><AfterHour_Holiday_Start xml:space="preserve">     </AfterHour_Holiday_Start><StationHoliday><xs:schema id="NewDataSet"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="StationHoliday" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="StationHoliday"><xs:complexType><xs:sequence><xs:element name="Date" type="xs:string" minOccurs="0"/><xs:element name="Holiday_description" type="xs:string" minOccurs="0"/><xs:element name="OpenHour" type="xs:string" minOccurs="0"/><xs:element name="CloseHour" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram><DocumentElement><StationHoliday diffgr:id="StationHoliday1" msdata:rowOrder="0"><Date>2016-06-19</Date><Holiday_description>Midsummer</Holiday_description><OpenHour>00:00</OpenHour><CloseHour>23:59</CloseHour></StationHoliday><StationHoliday diffgr:id="StationHoliday2" msdata:rowOrder="1"><Date>2016-06-20</Date><Holiday_description>Midsummer</Holiday_description><OpenHour>00:00</OpenHour><CloseHour>23:59</CloseHour></StationHoliday><StationHoliday diffgr:id="StationHoliday3" msdata:rowOrder="2"><Date>2016-06-21</Date><Holiday_description>Midsummer</Holiday_description><OpenHour>00:00</OpenHour><CloseHour>23:59</CloseHour></StationHoliday><StationHoliday diffgr:id="StationHoliday4" msdata:rowOrder="3"><Date>2016-08-18</Date><Holiday_description>Midsummer</Holiday_description><OpenHour>00:00</OpenHour><CloseHour>23:59</CloseHour></StationHoliday></DocumentElement></diffgr:diffgram></StationHoliday><Schedule><xs:schema id="NewDataSet"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="StationHoliday" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="StationHoliday"><xs:complexType><xs:sequence><xs:element name="SeasonStart" type="xs:string" minOccurs="0"/><xs:element name="SeasonEnd" type="xs:string" minOccurs="0"/><xs:element name="MondayAHStart" type="xs:string" minOccurs="0"/><xs:element name="MondayOpen" type="xs:string" minOccurs="0"/><xs:element name="MondayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="MondayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="MondayClose" type="xs:string" minOccurs="0"/><xs:element name="MondayAHEnd" type="xs:string" minOccurs="0"/><xs:element name="TuesdayAHStart" type="xs:string" minOccurs="0"/><xs:element name="TuesdayOpen" type="xs:string" minOccurs="0"/><xs:element name="TuesdayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="TuesdayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="TuesdayClose" type="xs:string" minOccurs="0"/><xs:element name="TuesdayAHEnd" type="xs:string" minOccurs="0"/><xs:element name="WednesdayAHStart" type="xs:string" minOccurs="0"/><xs:element name="WednesdayOpen" type="xs:string" minOccurs="0"/><xs:element name="WednesdayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="WednesdayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="WednesdayClose" type="xs:string" minOccurs="0"/><xs:element name="WednesdayAHEnd" type="xs:string" minOccurs="0"/><xs:element name="ThursdayAHStart" type="xs:string" minOccurs="0"/><xs:element name="ThursdayOpen" type="xs:string" minOccurs="0"/><xs:element name="ThursdayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="ThursdayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="ThursdayClose" type="xs:string" minOccurs="0"/><xs:element name="ThursdayAHEnd" type="xs:string" minOccurs="0"/><xs:element name="FridayAHStart" type="xs:string" minOccurs="0"/><xs:element name="FridayOpen" type="xs:string" minOccurs="0"/><xs:element name="FridayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="FridayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="FridayClose" type="xs:string" minOccurs="0"/><xs:element name="FridayAHEnd" type="xs:string" minOccurs="0"/><xs:element name="SaturdayAHStart" type="xs:string" minOccurs="0"/><xs:element name="SaturdayOpen" type="xs:string" minOccurs="0"/><xs:element name="SaturdayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="SaturdayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="SaturdayClose" type="xs:string" minOccurs="0"/><xs:element name="SaturdayAHEnd" type="xs:string" minOccurs="0"/><xs:element name="SundayAHStart" type="xs:string" minOccurs="0"/><xs:element name="SundayOpen" type="xs:string" minOccurs="0"/><xs:element name="SundayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="SundayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="SundayClose" type="xs:string" minOccurs="0"/><xs:element name="SundayAHEnd" type="xs:string" minOccurs="0"/><xs:element name="HolidayAHStart" type="xs:string" minOccurs="0"/><xs:element name="HolidayOpen" type="xs:string" minOccurs="0"/><xs:element name="HolidayLunchStart" type="xs:string" minOccurs="0"/><xs:element name="HolidayLunchEnd" type="xs:string" minOccurs="0"/><xs:element name="HolidayClose" type="xs:string" minOccurs="0"/><xs:element name="HolidayAHEnd" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram><DocumentElement><StationHoliday diffgr:id="StationHoliday1" msdata:rowOrder="0"><SeasonStart>01/01</SeasonStart><SeasonEnd>31/12</SeasonEnd><MondayAHStart xml:space="preserve">     </MondayAHStart><MondayOpen>00:00</MondayOpen><MondayLunchStart xml:space="preserve">     </MondayLunchStart><MondayLunchEnd xml:space="preserve">     </MondayLunchEnd><MondayClose>23:59</MondayClose><MondayAHEnd xml:space="preserve">     </MondayAHEnd><TuesdayAHStart xml:space="preserve">     </TuesdayAHStart><TuesdayOpen>00:00</TuesdayOpen><TuesdayLunchStart xml:space="preserve">     </TuesdayLunchStart><TuesdayLunchEnd xml:space="preserve">     </TuesdayLunchEnd><TuesdayClose>23:59</TuesdayClose><TuesdayAHEnd xml:space="preserve">     </TuesdayAHEnd><WednesdayAHStart xml:space="preserve">     </WednesdayAHStart><WednesdayOpen>00:00</WednesdayOpen><WednesdayLunchStart xml:space="preserve">     </WednesdayLunchStart><WednesdayLunchEnd xml:space="preserve">     </WednesdayLunchEnd><WednesdayClose>23:59</WednesdayClose><WednesdayAHEnd xml:space="preserve">     </WednesdayAHEnd><ThursdayAHStart xml:space="preserve">     </ThursdayAHStart><ThursdayOpen>00:00</ThursdayOpen><ThursdayLunchStart xml:space="preserve">     </ThursdayLunchStart><ThursdayLunchEnd xml:space="preserve">     </ThursdayLunchEnd><ThursdayClose>23:59</ThursdayClose><ThursdayAHEnd xml:space="preserve">     </ThursdayAHEnd><FridayAHStart xml:space="preserve">     </FridayAHStart><FridayOpen>00:00</FridayOpen><FridayLunchStart xml:space="preserve">     </FridayLunchStart><FridayLunchEnd xml:space="preserve">     </FridayLunchEnd><FridayClose>23:59</FridayClose><FridayAHEnd xml:space="preserve">     </FridayAHEnd><SaturdayAHStart xml:space="preserve">     </SaturdayAHStart><SaturdayOpen>00:00</SaturdayOpen><SaturdayLunchStart xml:space="preserve">     </SaturdayLunchStart><SaturdayLunchEnd xml:space="preserve">     </SaturdayLunchEnd><SaturdayClose>23:59</SaturdayClose><SaturdayAHEnd xml:space="preserve">     </SaturdayAHEnd><SundayAHStart xml:space="preserve">     </SundayAHStart><SundayOpen>00:00</SundayOpen><SundayLunchStart xml:space="preserve">     </SundayLunchStart><SundayLunchEnd xml:space="preserve">     </SundayLunchEnd><SundayClose>23:59</SundayClose><SundayAHEnd xml:space="preserve">     </SundayAHEnd><HolidayAHStart xml:space="preserve">     </HolidayAHStart><HolidayOpen>00:00</HolidayOpen><HolidayLunchStart xml:space="preserve">     </HolidayLunchStart><HolidayLunchEnd xml:space="preserve">     </HolidayLunchEnd><HolidayClose>23:59</HolidayClose><HolidayAHEnd xml:space="preserve">     </HolidayAHEnd></StationHoliday></DocumentElement></diffgr:diffgram></Schedule></Table></StationDetails></diffgr:diffgram></stationDetails></StationDetailsResult></StationDetailsResponse></soap:Body></soap:Envelope>

0 个答案:

没有答案