我有以下 XML:
<RULES>
<TRAP name="trap1" oid=".1.2.3">
<VAR_LIST>
<VAR name="var1" value=".1.2.3.1"/>
<VAR name="var2" value=".1.2.3.2"/>
</VAR_LIST>
</TRAP>
<TRAP name="trap2" oid=".1.2.4">
...
</TRAP>
...
</RULES>
我想生成扁平化摘要,所以我按如下方式遍历它:
for $trap in /RULES/TRAP
for $var in $rule/VAR_LIST/VAR
return (opening-tag-declaration($trap), opening-tag-declaration($var), " ")
我想得到以下输出,但我不知道如何只提取标签的开始声明......
<TRAP name="trap1" oid=".1.2.3> <VAR name="var1" value=".1.2.3.1"/>
<TRAP name="trap1" oid=".1.2.3> <VAR name="var2" value=".1.2.3.2"/>
<TRAP name="trap2" oid=".1.2.4> ...
...