<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SEGMEM>
<FIELD>
<Entry type="Field">
<MemoryVariable>x</MemoryVariable>
<Variable>x(v9)</Variable>
<offset>
<lowerBound>0</lowerBound>
<upperBound>31</upperBound>
</offset>
</Entry>
<Entry type="Field">
<MemoryVariable>LE</MemoryVariable>
<Variable>LE(v10)</Variable>
<offset>
<lowerBound>0</lowerBound>
<upperBound>0</upperBound>
</offset>
</Entry>
</FIELD>
<CONGRUENCES>
<Entry type="congruence">
<Variable>v6</Variable>
<Value>
<multiplier>0</multiplier>
<offset>1</offset>
</Value>
</Entry>
<Entry type="congruence">
<Variable>x(v9)</Variable>
<Value>
<multiplier>1</multiplier>
<offset>0</offset>
</Value>
</Entry>
</CONGRUENCES>
</SEGMEM>
我有上面的 XML。<Entry type="Field">
我需要搜索常见的变量元素 <Entry type="congruence">
。变量只会显示一次。
输出应如下所示:
<table border="1">
<tr bgcolor="#9acd32">
<th>MemoryVariable</th>
<th>Variable</th>
<th>lowerbound/upperbound</th>
<th>multiplier/offset</th>
</tr>
<tr>
<td>x</td> <!-- memory variable -->
<td>x(v9)</td> <!-- x(v9) is the in file and congruence entry -->
<td>[0,31]</td> <!-- lowerbound and upperbound -->
<td>[1,0]</td> <!-- <multiplier>1</multiplier> <offset>0</offset> -->
</tr>
<tr>
<td>LE</td> <!-- memory variable again -->
<td>LE(v10)</td><!-- LE(v10) is the in file and not in congruence entry -->
<td>[0,0]</td> <!-- lowerbound and upperbound -->
<td>null</td> <!-- <multiplier>null</multiplier> <offset>null</offset> -->
</tr>
<tr>
<td>null</td> <!-- memory variable again -->
<td>v6</td> <!-- v6 is the not in file but in congruence entry -->
<td>null</td> <!-- lowerbound and upperbound -->
<td>[0,1]</td> <!-- <multiplier>0</multiplier> <offset>1</offset> -->
</tr>
</table>
哪位高手可以给出解决方案?我解决不了。