2013-01-21 23 views
1

我完全不熟悉XML及其功能。分發XML文件

我有一個文件說xyz.xml。 它包含了這樣的內容:

<system-config> 
    <business-model> 
     <agent-category key="operator"> 
     <singular-name>Operator</singular-name> 
     <plural-name>Operators</plural-name> 
     <attribute>agent-attribute.reference</attribute> 
     </agent-category> 

接下來我有

<agent-attribute id="agent-attribute.reference"> 
    <name>Reference</name> 
    < description>A unique identifier for this agent, typically an MSISDN.</description> 
    <mandatory>true< /mandatory> 
    <editable>false< /editable> 
    <deletable>false< /deletable> 
    <sensitive>false< /sensitive> 
    <system-generated>false< /system-generated> 
    <input-method xsi:type="AgentReferenceInputMethod"></input-method> 
    <storage-location xsi:type="AgentRefStorage" field="reference"></storage-location> 
    </agent-attribute> 
</business-model> 

現在我要分發的代理屬性命名agentAttr.xml不同的文件。

是否有可能這樣做(介意它<agent-attribute>是在<system-config><business-model>),如果是的話如何?

+0

解析XML文件並創建一個新的屬性?我不確定我是否理解這個問題。 – kutschkem

+0

它基於System-Config XML的Schema和將使用此XML的應用程序。如果它要求在同一個文件中存在'agent-attribute';你不能分發它。 –

+0

好吧,這意味着沒有別的辦法可以編碼。這意味着XML本身不提供任何此類功能。感謝那些幫助我很多的回覆。 –

回答

1

所以你想提取代理屬性部分?您可以通過簡單的XSLT轉換來完成此操作(例如,使用Xalan)。另一個選項可能是jsoup,使用DOM解析或手動解析。