可能重复:
How do you rename a tag in SimpleXML through a DOM object?
如果我有这样的XML文档:
<document>
<dogs>
<bulldog>Blu</bulldog>
<terrier>Benjie</terrier>
</dogs>
<cats>
<tiger>Tiggger</tiger>
<lion>Cowardly</lion>
</cats>
</document>
我想重新打印它,添加一些属性,但不保留原始....
<document>
<canine type="fiction">
<bulldog>Blu</bulldog>
<terrier>Benjie</terrier>
</canine>
<feline type="fiction">
<tiger>Tiggger</tiger>
<lion>Cowardly</lion>
</feline>
</document>
我在SimpleXML中使用什么策略?