一 需求
要求希望实现可以用 java 比对两个 xml 文件的不同,第二种方法,使用 CommandVisitor 实现。
二 实例
2.1 准备
- 准备 一个 difftemplate.html 文件,文件内容为:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial;
color: black;
}
.split {
height: 100%;
width: 50%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
.left {
left: 0;
background-color: #D7FBF6;
}
.right {
right: 0;
background-color: #FCFCC3;
}
</style>
</head>
<body>
<div class="split left">
<div class="centered">
<p>${left}</p>
</div>
</div>
<div class="split right">
<div class="centered">
<p>${right}</p>
</div>
</div>
</body>
</html>
- 准备两个待比对的文件(最好是文本文件),我由于业务需要比对xml 文件,所以准备了两个 xml 文件,内容为:
preconfig.xml
<xml>
<abc>
<id>1</id>
<