使用JavaScript删除XML命名空间的简单方法? [英] Easy way to drop XML Namespaces with JavaScript?

查看:125
本文介绍了使用JavaScript删除XML命名空间的简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 < html:a href =#an-exampletitle =转到示例>只是一个例子< / html:a> 

并将其更改为:

<$ p $ <> c $ c>< a href =#an-exampletitle =转到示例>只是一个示例< / a>

使用jQuery或JavaScript并且不知道里面的元素和/或属性?

解决方案

如果代码中没有< script> 可以尝试演示

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


Is there an easy way, for example, to drop an XML name space, but keep the tag as is with jQuery or JavaScript? For example:

<html:a href="#an-example" title="Go to the example">Just an Example</html:a>

And change it to:

<a href="#an-example" title="Go to the example">Just an Example</a>

On the fly with jQuery or JavaScript and not knowing the elements and or attributes inside?

解决方案

If there is no <script> tag in the code to be replaced you can try (demo):

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

这篇关于使用JavaScript删除XML命名空间的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆