我正在开发应用程序,我必须根据唯一的 IPADDRESS 标签比较 2 个 xml。例如:input1.xml
<DeviceList>
<Device>
<IPAddress>20.20.1.20</IPAddress>
<HostName>Device1</HostName>
</Device>
<Device>
<IPAddress>20.20.1.21</IPAddress>
<HostName>Device2</HostName>
</Device>
<Device>
<IPAddress>20.20.1.22</IPAddress>
<HostName>Device3</HostName>
</Device>
</DeviceList>
inpu2.xml
<DeviceList>
<Device>
<IPAddress>20.20.1.23</IPAddress>
<HostName>Device1</HostName>
</Device>
<Device>
<IPAddress>20.20.1.21</IPAddress>
<HostName>Device3</HostName>
</Device>
<Device>
<IPAddress>20.20.1.22</IPAddress>
<HostName>Device3</HostName>
</Device>
</DeviceList>
Result should be two xmls
output1 : ipadrees are present in input2.xml and not present in input.xml1
<DeviceList>
<Device>
<IPAddress>10.20.1.23</IPAddress>
<HostName>Device1</HostName>
</Device>
</DeviceList>
output2 : Remaining device list in input1.xml
<DeviceList>
<Device>
<IPAddress>10.20.1.20</IPAddress>
<HostName>Device1</HostName>
</Device>
<Device>
<IPAddress>10.20.1.21</IPAddress>
<HostName>Device2</HostName>
</Device>
<Device>
<IPAddress>10.20.1.22</IPAddress>
<HostName>Device3</HostName>
</Device>
</DeviceList>
我尝试使用 XMLUNIT java api,但无法做到,因为我们应该只基于 IPAddress 标签进行过滤。请提前帮助并感谢。