原始(较旧)文件:
<?xml version="1.0" encoding="UTF-8"?>
<notes version="1">
<labels>
<label id="0" color="80FF80">BadReg</label>
<label id="1" color="FFFF40">GoodReg</label>
<label id="2" color="8000FF">Bluffer</label>
<label id="3" color="10FF10">Fish</label>
<label id="4" color="1080FF">Loose</label>
<label id="5" color="30DBFF">Semi-Loose</label>
<label id="6" color="FF">Nit</label>
<label id="7" color="FF9F48">Tight</label>
<label id="8" color="C0C0C0">Undefined</label>
</labels>
<note player=""Seikei"&5RS" label="8" update="1429734930"></note>
<note player="#23Mattingly" label="5" update="1429734930">Note1</note>
<note player="#PachnacyBak" label="7" update="1429734930">Note2</note>
<note player="$attlaz" label="3" update="1429734930">Note3</note>
</notes>
合并:
<?xml version="1.0" encoding="UTF-8"?>
<notes version="1">
<labels>
<label id="0" color="80FF80">BadReg</label>
<label id="1" color="FFFF40">GoodReg</label>
<label id="2" color="8000FF">Bluffer</label>
<label id="3" color="10FF10">Fish</label>
<label id="4" color="1080FF">Loose</label>
<label id="5" color="30DBFF">Semi-Loose</label>
<label id="6" color="0000FF">Nit</label>
<label id="7" color="FF9F48">Tight</label>
<label id="8" color="C0C0C0">Undefined</label>
</labels>
<note player=""Seikei"&5RS" label="8" update="1429734930"></note>
<note player="#23Mattingly" label="5" update="1429734930"></note>
<note player="#PachnacyBak" label="7" update="1429734930"></note>
<note player="$attlaz" label="2" update="1429734930"></note>
<note player="111kakarot" label="1" update="1429734930"></note>
<note player="111PO111" label="2" update="1429734930"></note>
</notes>
输出我希望得到:
<?xml version="1.0" encoding="UTF-8"?>
<notes version="1">
<labels>
<label id="0" color="80FF80">BadReg</label>
<label id="1" color="FFFF40">GoodReg</label>
<label id="2" color="8000FF">Bluffer</label>
<label id="3" color="10FF10">Fish</label>
<label id="4" color="1080FF">Loose</label>
<label id="5" color="30DBFF">Semi-Loose</label>
<label id="6" color="0000FF">Nit</label>
<label id="7" color="FF9F48">Tight</label>
<label id="8" color="C0C0C0">Undefined</label>
</labels>
<note player=""Seikei"&5RS" label="8" update="1429734930"></note>
<note player="#23Mattingly" label="5" update="1429734930">Note1</note>
<note player="#PachnacyBak" label="7" update="1429734930">Note2</note>
<note player="$attlaz" label="2" update="1429734930">Note3</note>
<note player="111kakarot" label="1" update="1429734930"></note>
<note player="111PO111" label="2" update="1429734930"></note>
</notes>
规则是:如果已经存在具有相同玩家ID的行,那么我只想用新文件中的值替换标签号,并且如果旧版中的更新标记后面有任何注释我希望在合并的输出文件中保留该注释,但如果新文件中的标签号不同,则更改标签号。其次:如果较新文件中的某一行在旧文件中没有匹配的玩家ID,那么我想在合并的输出文件中复制整行。样品在上面。