How do you rename a tag in SimpleXML through a DOM object?

后端 未结 4 432
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 00:51

The problem seems straightforward, but I\'m having trouble getting access to the tag name of a SimpleXMLElement.

Let\'s say I have the follow XML structure:

4条回答
  •  有刺的猬
    2020-12-02 01:27

    Maybe easier way would be to replace the tags using preg functions for the XML source string?

    Cleaner way

    Create XSLT XML transformation file and use xsl PHP extension to translate it.

    For this see this answer – Rename nodes with XSLT. PHP code part could be found in PHP documentation.

提交回复
热议问题