我有以下要解析的 XML。重复的属性名称使获得我想要的输出变得困难。
这个问题的一个明显的解决方案似乎是改变属性分数的值。
<linescore score="129">
<quarter quarter="1" score="16"/>
<quarter quarter="2" score="30"/>
<quarter quarter="3" score="42"/>
<quarter quarter="4" score="27"/>
<quarter quarter="5" score="9"/>
<quarter quarter="6" score="5"/>
您如何根据季度值更改 score 值?例如:
<linescore score="129">
<quarter quarter="1" score="16_1"/>
<quarter quarter="2" score="30_2"/>
<quarter quarter="3" score="42_3"/>
<quarter quarter="4" score="27_4"/>
<quarter quarter="5" score="9_5"/>
<quarter quarter="6" score="5_6"/>
我试过使用xml_replace
但没有成功。