2016-09-28 6 views
0

ich eine XML-Antwort von einem api haben wie folgt formatiert:Deserialize verschachtelte XML-Knoten

<?xml version='1.0' encoding='UTF-8'?> 
<response success="true"> 
    <messages> 
     <message type="WARNING" key="warning-unpublished-changes" values="" parentId="1"> 
      You have unpublished changes. Your changes will not be visible every where until it is published.</message> 
    </messages> 
    <output> 
     <accounts> 
      <account 
       id="1" 
       code="AssetsChild" 
       name="AssetsChild" 
       description="Total Assets Child" 
       displayAs="CURRENCY" 
       accountTypeCode="A" 
       decimalPrecision="0" 
       isAssumption="0" 
       suppressZeroes="1" 
       isDefaultRoot="1" 
       shortName="" 
       exchangeRateType="E" 
       balanceType="DEBIT" 
       formula="" 
       isLinked="0" 
       owningSheetId="" 
       isSystem="0" 
       isIntercompany="0" 
       dataEntryType="" 
       planBy="DELTA" 
       timeRollup="LAST" 
       timeWeightAcctId="" 
       levelDimRollup="SUM" 
       levelDimWeightAcctId="" 
       rollupText="" 
       startExpanded="1" 
       hasSalaryDetail="" 
       dataPrivacy="PRIVATE" 
       isBreakbackEligible="" 
       subType="CUMULATIVE" 
       enableActuals="1" 
       isGroup="0" 
      /> 
     </accounts> 
    </output> 
</response> 

Ich möchte es auf ein Antwortobjekt haben deserialisiert wie folgt definiert:

class Response 
{ 
    protected $success; 
    protected $messages; 
    protected $accounts; 
} 

Ich bin in der Lage gewesen, den Erfolgswert und das Nachrichtenfeld erfolgreich zu erhalten, indem ich die folgende Konfiguration benutze. Ist es möglich, die accounts-Eigenschaft mit der Liste der Account-Knoten zu hydratisieren?

Response\AccountResponse: 
    xml_root_name: response 
    properties: 
    success: 
     type: boolean 
     xml_attribute: true 
     xml_value: false 

    messages: 
     type: array<Entity\Message> 
     xml_list: 
     entry_name: message 

Antwort