2016-09-28 145 views
0

我得從格式化爲一個API的XML響應如下:反序列化嵌套的XML節點

<?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> 

我想擁有它反序列化到響應對象定義爲:

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

我已經能夠使用下面的配置成功獲取成功值和消息數組。是否有可能通過賬戶節點列表獲得賬戶屬性的水合物?

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 

回答