simplexml_load_string没有得到所有的xml元素?

时间:2016-03-30 11:33:40

标签: php xml soap

我有这个xml回复

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <SearchInvoiceResponse xmlns="http://invers.com/cocosoft/invoices/">
         <SearchInvoiceResult xmlns:a="http://schemas.datacontract.org/2004/07/Invers.DataTypes" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:ErrorMessage />
            <a:SuccessCode>1</a:SuccessCode>
            <a:Timestamp>
               <a:Timezone>-2147483568</a:Timezone>
               <a:UTCDateTime>2016-03-30T13:52:06.5136279Z</a:UTCDateTime>
            </a:Timestamp>
            <a:ListData xmlns:b="http://invers.com">
               <b:Invoice>
                  <b:Account>
                     <ExternalId xmlns="http://invers.com/cocosoft/masterdata/" i:nil="true" />
                     <Id xmlns="http://invers.com/cocosoft/masterdata/">11</Id>
                     <SysTimestamp xmlns="http://invers.com/cocosoft/masterdata/">2016-02-28T05:12:44</SysTimestamp>
                     <Syu_Ref xmlns="http://invers.com/cocosoft/masterdata/">126</Syu_Ref>
                     <Provider_Ref xmlns="http://invers.com/cocosoft/masterdata/">1</Provider_Ref>
                     <State xmlns="http://invers.com/cocosoft/masterdata/">Active</State>
                     <Name xmlns="http://invers.com/cocosoft/masterdata/">AC EKAR_User</Name>
                     <Remark_External xmlns="http://invers.com/cocosoft/masterdata/" i:nil="true" />
                     <Remark_Internal xmlns="http://invers.com/cocosoft/masterdata/" i:nil="true" />
                     <CompanyName xmlns="http://invers.com/cocosoft/masterdata/" i:nil="true" />
                     <CompanyNumber xmlns="http://invers.com/cocosoft/masterdata/" i:nil="true" />
                     <ExternalPaymentMethodsIdentifier xmlns="http://invers.com/cocosoft/masterdata/">Ex method EKARuser1</ExternalPaymentMethodsIdentifier>
                     <InvoiceRecipient_Ref xmlns="http://invers.com/cocosoft/masterdata/">11</InvoiceRecipient_Ref>
                     <IsSharedAccount xmlns="http://invers.com/cocosoft/masterdata/">false</IsSharedAccount>
                     <b:InvoiceRecipient>
                        <ExternalId xmlns="http://invers.com/cocosoft/masterdata/" i:nil="true" />
                        <Id xmlns="http://invers.com/cocosoft/masterdata/">11</Id>
                        <SysTimestamp xmlns="http://invers.com/cocosoft/masterdata/">2016-02-28T05:12:44</SysTimestamp>
                        <Syu_Ref xmlns="http://invers.com/cocosoft/masterdata/">126</Syu_Ref>
                        <Provider_Ref xmlns="http://invers.com/cocosoft/masterdata/">1</Provider_Ref>
                        <State xmlns="http://invers.com/cocosoft/masterdata/">Active</State>
                        <Name xmlns="http://invers.com/cocosoft/masterdata/">IR EKAR_User</Name>
                        <Remark_External xmlns="http://invers.com/cocosoft/masterdata/" />
                        <Remark_Internal xmlns="http://invers.com/cocosoft/masterdata/" />
                        <BankAccountNumber xmlns="http://invers.com/cocosoft/masterdata/" />
                        <BankAccountOwner xmlns="http://invers.com/cocosoft/masterdata/">Ekar User</BankAccountOwner>
                        <BankIban xmlns="http://invers.com/cocosoft/masterdata/" />
                        <BankIdentifierCode xmlns="http://invers.com/cocosoft/masterdata/" />
                        <BankName xmlns="http://invers.com/cocosoft/masterdata/" />
                        <BankNumber xmlns="http://invers.com/cocosoft/masterdata/" />
                        <DebitorNumber xmlns="http://invers.com/cocosoft/masterdata/" />
                        <PaymentType xmlns="http://invers.com/cocosoft/masterdata/">Unknown</PaymentType>
                        <Person_Ref xmlns="http://invers.com/cocosoft/masterdata/">13</Person_Ref>
                        <SepaMandateId xmlns="http://invers.com/cocosoft/masterdata/" />
                        <SepaMandateIssueDate xmlns="http://invers.com/cocosoft/masterdata/" i:nil="true" />
                        <ShipmentEmail xmlns="http://invers.com/cocosoft/masterdata/">true</ShipmentEmail>
                        <ShipmentPost xmlns="http://invers.com/cocosoft/masterdata/">false</ShipmentPost>
                        <b:Addresses xmlns:c="http://invers.com/cocosoft/masterdata/" />
                        <b:Communications xmlns:c="http://invers.com/cocosoft/masterdata/" />
                        <b:Person xmlns:c="http://invers.com/cocosoft/masterdata/">
                           <c:ExternalId i:nil="true" />
                           <c:Id>13</c:Id>
                           <c:SysTimestamp>2016-01-13T08:05:19</c:SysTimestamp>
                           <c:Syu_Ref>126</c:Syu_Ref>
                           <c:Provider_Ref>1</c:Provider_Ref>
                           <c:State>Active</c:State>
                           <c:Name>User</c:Name>
                           <c:Remark_External />
                           <c:Remark_Internal />
                           <c:AvailableForCleaningWork>false</c:AvailableForCleaningWork>
                           <c:AvailableForHandlingNotes>false</c:AvailableForHandlingNotes>
                           <c:AvailableForMaintenanceWork>false</c:AvailableForMaintenanceWork>
                           <c:AvailableForTechnologyWorkAtLocations>false</c:AvailableForTechnologyWorkAtLocations>
                           <c:AvailableForTechnologyWorkForItems>false</c:AvailableForTechnologyWorkForItems>
                           <c:BCSALanguage>BCSA</c:BCSALanguage>
                           <c:Birthday i:nil="true" />
                           <c:DriverLicenseClass />
                           <c:DriverLicenseExpirationDate i:nil="true" />
                           <c:DriverLicenseIssueDate i:nil="true" />
                           <c:DriverLicenseNumber />
                           <c:DriverLicensePlaceOfIssue />
                           <c:FirstName>Ekar</c:FirstName>
                           <c:Gender>Undefined</c:Gender>
                           <c:Name_Affix />
                           <c:PartnerPerson i:nil="true" />
                           <c:PersonnelNumber />
                           <c:TitleAddress />
                           <c:Addresses />
                           <c:Communications>
                              <c:SearchCommunication>
                                 <c:ExternalId i:nil="true" />
                                 <c:Id>7</c:Id>
                                 <c:SysTimestamp>2016-01-13T07:43:06</c:SysTimestamp>
                                 <c:Syu_Ref>126</c:Syu_Ref>
                                 <c:Provider_Ref>1</c:Provider_Ref>
                                 <c:State>Active</c:State>
                                 <c:Name i:nil="true" />
                                 <c:Remark_External i:nil="true" />
                                 <c:Remark_Internal i:nil="true" />
                                 <c:Address>sandra@ekar.ae</c:Address>
                                 <c:CustomerType>Private</c:CustomerType>
                                 <c:InvoiceRecipient_Ref>0</c:InvoiceRecipient_Ref>
                                 <c:Notify>1</c:Notify>
                                 <c:Person_Ref>13</c:Person_Ref>
                                 <c:TextOnly>0</c:TextOnly>
                                 <c:Type>Email</c:Type>
                              </c:SearchCommunication>
                              <c:SearchCommunication>
                                 <c:ExternalId i:nil="true" />
                                 <c:Id>10</c:Id>
                                 <c:SysTimestamp>2016-01-13T07:57:26</c:SysTimestamp>
                                 <c:Syu_Ref>126</c:Syu_Ref>
                                 <c:Provider_Ref>1</c:Provider_Ref>
                                 <c:State>Active</c:State>
                                 <c:Name i:nil="true" />
                                 <c:Remark_External i:nil="true" />
                                 <c:Remark_Internal i:nil="true" />
                                 <c:Address>+971525180110</c:Address>
                                 <c:CustomerType>Private</c:CustomerType>
                                 <c:InvoiceRecipient_Ref>0</c:InvoiceRecipient_Ref>
                                 <c:Notify>1</c:Notify>
                                 <c:Person_Ref>13</c:Person_Ref>
                                 <c:TextOnly>0</c:TextOnly>
                                 <c:Type>Mobile</c:Type>
                              </c:SearchCommunication>
                           </c:Communications>
                           <c:ReservationRemark_External i:nil="true" />
                           <c:ReservationRemark_Internal i:nil="true" />
                           <c:Systemuser>
                              <c:SearchSystemuser>
                                 <c:ExternalId i:nil="true" />
                                 <c:Id>133</c:Id>
                                 <c:SysTimestamp>2016-01-13T08:05:19</c:SysTimestamp>
                                 <c:Syu_Ref>0</c:Syu_Ref>
                                 <c:Provider_Ref>1</c:Provider_Ref>
                                 <c:State>Active</c:State>
                                 <c:FavouriteLocationId i:nil="true" />
                                 <c:LoginName>EKAR_User</c:LoginName>
                                 <c:PartnerSystemuser i:nil="true" />
                                 <c:Person_Ref>13</c:Person_Ref>
                                 <c:Remark_External i:nil="true" />
                                 <c:Remark_Internal i:nil="true" />
                              </c:SearchSystemuser>
                           </c:Systemuser>
                        </b:Person>
                     </b:InvoiceRecipient>
                  </b:Account>
                  <b:AccountId>11</b:AccountId>
                  <b:Id>1</b:Id>
                  <b:InvoiceDate>2016-01-12T00:00:00</b:InvoiceDate>
                  <b:InvoicedAmount>129.1000</b:InvoicedAmount>
                  <b:Items>
                     <b:InvoiceItem>
                        <b:AccountId>11</b:AccountId>
                        <b:AutomaticItemtype>Other</b:AutomaticItemtype>
                        <b:ChangedUtc>2016-01-12T09:57:23</b:ChangedUtc>
                        <b:CrossusageItem xmlns:c="http://schemas.datacontract.org/2004/07/Invers.CocoSoft.Billing.Interface" i:nil="true" />
                        <b:CrossusageTransfer xmlns:c="http://schemas.datacontract.org/2004/07/Invers.CocoSoft.Billing.Interface" i:nil="true" />
                        <b:CustomerId>11</b:CustomerId>
                        <b:CustomerName>EKAR_User</b:CustomerName>
                        <b:Deleted>false</b:Deleted>
                        <b:ExclTax>true</b:ExclTax>
                        <b:Fees>0.0000</b:Fees>
                        <b:Id>2</b:Id>
                        <b:InvoiceId>1</b:InvoiceId>
                        <b:InvoicedAmount>129.1000</b:InvoicedAmount>
                        <b:InvoicedTax>0.0000</b:InvoicedTax>
                        <b:ItemId>1</b:ItemId>
                        <b:ItemName>Zurich the Sentra (7134)</b:ItemName>
                        <b:ItemTarifId>1</b:ItemTarifId>
                        <b:KmCost>17.1000</b:KmCost>
                        <b:LocationId>1</b:LocationId>
                        <b:LocationName>Dubai</b:LocationName>
                        <b:MemberTarifId>1</b:MemberTarifId>
                        <b:NoteId>0</b:NoteId>
                        <b:Nr>1</b:Nr>
                        <b:Parts>
                           <b:InvoiceItemPart>
                              <b:Amount>2.0000</b:Amount>
                              <b:BookkeepingCode i:nil="true" />
                              <b:Count>56</b:Count>
                              <b:FeeCategory i:nil="true" />
                              <b:From>2016-01-07T14:00:00</b:From>
                              <b:Id>3</b:Id>
                              <b:InvoiceItemId>2</b:InvoiceItemId>
                              <b:NewCalculated>true</b:NewCalculated>
                              <b:ProviderId>1</b:ProviderId>
                              <b:Reason>1/2 hour - anytime</b:Reason>
                              <b:SystemFeeType>Unknown</b:SystemFeeType>
                              <b:TaxRates />
                              <b:Type>TimePart</b:Type>
                              <b:Until>2016-01-08T18:00:00</b:Until>
                              <b:UpdateMode>Recalculate</b:UpdateMode>
                              <b:UserFeeType>0</b:UserFeeType>
                           </b:InvoiceItemPart>
                           <b:InvoiceItemPart>
                              <b:Amount>0.3000</b:Amount>
                              <b:BookkeepingCode i:nil="true" />
                              <b:Count>57</b:Count>
                              <b:FeeCategory i:nil="true" />
                              <b:From i:nil="true" />
                              <b:Id>4</b:Id>
                              <b:InvoiceItemId>2</b:InvoiceItemId>
                              <b:NewCalculated>true</b:NewCalculated>
                              <b:ProviderId>1</b:ProviderId>
                              <b:Reason i:nil="true" />
                              <b:SystemFeeType>Unknown</b:SystemFeeType>
                              <b:TaxRates />
                              <b:Type>KmPart</b:Type>
                              <b:Until i:nil="true" />
                              <b:UpdateMode>Recalculate</b:UpdateMode>
                              <b:UserFeeType>0</b:UserFeeType>
                           </b:InvoiceItemPart>
                        </b:Parts>
                        <b:PayableDate>2016-01-08T18:00:00</b:PayableDate>
                        <b:PayablePeriodId>0</b:PayablePeriodId>
                        <b:PreviousItemId>0</b:PreviousItemId>
                        <b:PricelistDate>2016-01-07T14:00:00</b:PricelistDate>
                        <b:PricelistId>1</b:PricelistId>
                        <b:ProviderId>1</b:ProviderId>
                        <b:Reservation xmlns:c="http://schemas.datacontract.org/2004/07/Invers.CocoSoft.Common.DataTypes.Entities">
                           <c:CallcenterTouches>0</c:CallcenterTouches>
                           <c:CategoryId>1</c:CategoryId>
                           <c:Changed>2016-01-07T10:22:05</c:Changed>
                           <c:CustomerId>11</c:CustomerId>
                           <c:ExtRemark />
                           <c:Free>false</c:Free>
                           <c:ID>100001</c:ID>
                           <c:Insurance>0</c:Insurance>
                           <c:ItemId>1</c:ItemId>
                           <c:ItemProv>1</c:ItemProv>
                           <c:LocationId>1</c:LocationId>
                           <c:PersonId>13</c:PersonId>
                           <c:ResHistId>0</c:ResHistId>
                           <c:Reservation16No>0</c:Reservation16No>
                           <c:SeriesId i:nil="true" />
                           <c:SmartcardId>8</c:SmartcardId>
                           <c:Start>
                              <a:Timezone>165</a:Timezone>
                              <a:UTCDateTime>2016-01-07T10:00:00Z</a:UTCDateTime>
                           </c:Start>
                           <c:State>3</c:State>
                           <c:Stop>
                              <a:Timezone>165</a:Timezone>
                              <a:UTCDateTime>2016-01-07T12:00:00Z</a:UTCDateTime>
                           </c:Stop>
                           <c:StopBeforeAutomaticChanges i:nil="true" />
                           <c:SysUserId>131</c:SysUserId>
                           <c:Type>1</c:Type>
                        </b:Reservation>
                        <b:ReservationId>100001</b:ReservationId>
                        <b:RevokeItem>false</b:RevokeItem>
                        <b:SysUserId>7</b:SysUserId>
                        <b:TarifEngineId>1</b:TarifEngineId>
                        <b:TimeCost>112.0000</b:TimeCost>
                        <b:TotalAmount>129.1000</b:TotalAmount>
                        <b:TotalTax>0.0000</b:TotalTax>
                        <b:UsageId>2</b:UsageId>
                     </b:InvoiceItem>
                  </b:Items>
                  <b:No>1</b:No>
                  <b:Period i:nil="true" />
                  <b:PeriodId>0</b:PeriodId>
                  <b:ProviderId>1</b:ProviderId>
                  <b:Remark_External i:nil="true" />
                  <b:Remark_Internal i:nil="true" />
                  <b:State>closed</b:State>
               </b:Invoice>
            </a:ListData>
            <a:MaxCount>266</a:MaxCount>
         </SearchInvoiceResult>
      </SearchInvoiceResponse>
   </s:Body>
</s:Envelope>

并尝试将其解析为像这样的关联数组

$response = htmlentities($response);
$response = str_replace("&lt;","<",$response);
$response = str_replace("&gt;",">",$response);
$response = str_replace("&quot;",'"',$response);
$response = str_replace("<s:Body>","",$response);
$response = str_replace("</s:Body>","",$response);

$parser = simplexml_load_string($response);
echo '<pre>';
print_r($parser);
echo '</pre>';

但结果是弄乱了大部分元素而且

    SimpleXMLElement Object
(
    [SearchInvoiceResponse] => SimpleXMLElement Object
        (
            [SearchInvoiceResult] => SimpleXMLElement Object
                (
                )

        )

)

请提前帮助并多多感谢。

0 个答案:

没有答案