我正在尝试将两个 xml 文件与基于条件的更新合并。在第一个文件中,您会注意到有 3 个 SECTION_SUMMARY 序列。第 3 个序列的 LockAuthority 属性为“1”。
File1.xml
<DOCUMENT>
<LOANS>
<LOAN SequenceNumber="1" xlink:label="LOAN1" LoanRoleType="SubjectLoan">
<DOCUMENT_SETS>
<DOCUMENT_SET>
<GFE>
<SECTION_SUMMARIES>
<SECTION_SUMMARY SequenceNumber="1">
<Amount>1975.00</Amount>
<Type>A</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="2">
<Amount>9751.44</Amount>
<Type>B</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="3" LockAuthority="1">
<Amount>3750.00</Amount>
<Type>A</Type>
</SECTION_SUMMARY>
</SECTION_SUMMARIES>
</GFE>
</DOCUMENT_SET>
</DOCUMENT_SETS>
<ESCROW>
<ESCROW_DETAIL>
<InsuranceIndicator>true</InsuranceIndicator>
<AllPropertyTaxesIndicator>true</AllPropertyTaxesIndicator>
<OtherDescription>HOA</OtherDescription>
</ESCROW_DETAIL>
</ESCROW>
</LOAN>
</LOANS>
</DOCUMENT>
在第二个文件中有序列 3 到 5。出现在两个文件中的序列 3 具有值为“2”的 LockAuthority 属性。如果值大于或等于文件 1 中的值,则值来自文件 2,否则值来自文件 1。我还想要合并 File1 中没有 LockAuthority 的任何数据点。如果没有 LockAuthority,则以 File2 中的数据为准。
File2.xml
<DOCUMENT>
<LOANS>
<LOAN SequenceNumber="1" xlink:label="LOAN1" LoanRoleType="SubjectLoan">
<DOCUMENT_SETS>
<DOCUMENT_SET>
<GFE>
<SECTION_SUMMARIES>
<SECTION_SUMMARY SequenceNumber="3" LockAuthority="2">
<Amount>200.00</Amount>
<Type>Header</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="4">
<Amount>-3000.00</Amount>
<Type>Two</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="5">
<Amount>5392.25</Amount>
<Type>Three</Type>
</SECTION_SUMMARY>
</SECTION_SUMMARIES>
</GFE>
</DOCUMENT_SET>
</DOCUMENT_SETS>
</LOAN>
</LOANS>
</DOCUMENT>
生成的文件应如下所示。
<DOCUMENT>
<LOANS>
<LOAN SequenceNumber="1" xlink:label="LOAN1" LoanRoleType="SubjectLoan">
<DOCUMENT_SETS>
<DOCUMENT_SET>
<GFE>
<SECTION_SUMMARIES>
<SECTION_SUMMARY SequenceNumber="1">
<Amount>1975.00</Amount>
<Type>A</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="2">
<Amount>9751.44</Amount>
<Type>B</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="3" LockAuthority="2">
<Amount>200.00</Amount>
<Type>Header</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="4">
<Amount>-3000.00</Amount>
<Type>Two</Type>
</SECTION_SUMMARY>
<SECTION_SUMMARY SequenceNumber="5">
<Amount>5392.25</Amount>
<Type>Three</Type>
</SECTION_SUMMARY>
</SECTION_SUMMARIES>
</GFE>
</DOCUMENT_SET>
</DOCUMENT_SETS>
<ESCROW>
<ESCROW_DETAIL>
<InsuranceIndicator>true</InsuranceIndicator>
<AllPropertyTaxesIndicator>true</AllPropertyTaxesIndicator>
<OtherDescription>HOA</OtherDescription>
</ESCROW_DETAIL>
</ESCROW>
</LOAN>
</LOANS>
</DOCUMENT>
非常感谢任何和所有帮助!