简体   繁体   English

使用Java比较2个xml负载

[英]Compare 2 xml payloads using Java

Iam automating rest services and in this automation i want to submit a xml payload and in the given response i will get the same payload.My question is to verify the out put and input pay loads are same(commented attributes and every thing should be compared) 我自动化休息服务,在这种自动化中,我想提交一个xml负载,并且在给定的响应中,我将获得相同的负载。我的问题是验证输出和输入的有效负载是否相同(注释的属性和每件事都应该进行比较)

Input 输入项

   <abc xsi:schemaLocation="https://abc.abc.com xyz.xsd" schemaVersion="1.0" xmlns="https://abc.abc.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <details>    <name>pawan</name>    <School>patrick</School>
         </details>

Output 输出量

   <abc xsi:schemaLocation="https://abc.abc.com xyz.xsd" schemaVersion="1.0" xmlns="https://abc.abc.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<details>
   <name>pawan</name>
   <School>patrick</School>
         </details>

Can any one help me with sample code of java to compare weather the input and output pay loads are equal or not. 任何人都可以用Java的示例代码来帮助我比较输入和输出有效载荷是否相等。

Try FileUtils.contentEquals(). 尝试FileUtils.contentEquals()。 It's part of the org.apache.commons.io package. 它是org.apache.commons.io软件包的一部分。 You'll need to have the jar in build path before using this method. 使用此方法之前,您需要在构建路径中包含jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM