使用JavaScript删除XML命名空间的简单方法?

Osc*_*son 5 html javascript jquery namespaces xml-namespaces

例如,是否有一种简单的方法来删除XML名称空间,但保持jQuery或JavaScript的标记不变?例如:

<html:a href="#an-example" title="Go to the example">Just an Example</html:a>
Run Code Online (Sandbox Code Playgroud)

并将其更改为:

<a href="#an-example" title="Go to the example">Just an Example</a>
Run Code Online (Sandbox Code Playgroud)

使用jQuery或JavaScript实时运行,并且不知道其中的元素和/或属性?

gbl*_*zex 4

<script>如果代码中没有要替换的标签可以尝试demo

container.innerHTML = container.innerHTML
                               .replace(/<(\/?)([^:>\s]*:)?([^>]+)>/g, "<$1$3>")
Run Code Online (Sandbox Code Playgroud)

  • 太棒了,你摇滚,这正是我所需要的! (2认同)