如有这样的xml 文档
<?xml version="1.0" encoding="GB2312" ?>
- <root>
root text
<author name="James" location="UK">James Strachan</author>
<author name="Bob" location="US">Bob McWhirter</author>
</root>怎样通过代码修改<root>为<newroot>标签
修改后的文档应该是这样的
<?xml version="1.0" encoding="GB2312" ?>
- <newroot>
root text
<author name="James" location="UK">James Strachan</author>
<author name="Bob" location="US">Bob McWhirter</author>
</newroot>
<?xml version="1.0" encoding="GB2312" ?>
- <root>
root text
<author name="James" location="UK">James Strachan</author>
<author name="Bob" location="US">Bob McWhirter</author>
</root>怎样通过代码修改<root>为<newroot>标签
修改后的文档应该是这样的
<?xml version="1.0" encoding="GB2312" ?>
- <newroot>
root text
<author name="James" location="UK">James Strachan</author>
<author name="Bob" location="US">Bob McWhirter</author>
</newroot>
你可以用正则表示式先找到要改的地方,然后替换,然后再重新写入文件不就可以了吗