问题描述
如果我有:
<?xml version =" 1.0" encoding =" UTF-8"?>
< pets>
< cats>
< cat1 color =" black" />
< cat2 color =" red" />
< / cats>
< / pets>
我想获得下一个输出:
misus1 color2 =" black"
misus2 color2 =" red"
, - 将元素cat1更改为misus1,将颜色属性更改为color2。
我该怎么办?这个?
if I have:
<?xml version="1.0" encoding="UTF-8"?>
<pets>
<cats>
<cat1 color="black"/>
<cat2 color="red"/>
</cats>
</pets>
And I want to get next output:
misus1 color2="black"
misus2 color2="red"
,- change element cat1 to misus1, attribute color to color2.
How can I do this?
推荐答案
我试图用for each来实现这个目的。和属性集 (对于每个元素来改变它们的名字......),但我得到一个错误意外的孩子,它指向属性集...
I tried to implement this using "for each" and "attribute-set" (for each element to change their names...), but I get an error "unexpected child", it points to attribute-set...
这篇关于重命名属性和元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!