分发XML文件

时间:2013-01-21 08:43:02

标签: java 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>

现在我想将agent-attributes分发到名为agentAttr.xml的不同文件。

是否可以这样做(请注意<agent-attribute><system-config><business-model>下),如果是这样的话?

1 个答案:

答案 0 :(得分:1)

所以你想提取代理属性部分?您可以通过简单的XSLT转换来实现这一点(例如,使用Xalan)。另一个选项可能是jsoup,使用DOM或手动解析它。