使用 Javascript/JQuery 进行 XML/XSL 转换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14988645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XML/XSL transform using Javascript/JQuery
提问by cgdeveloper
Can anyone tell me if there is a way to do an XML/XSLT transformation on the client side using Javascript or JQuery, a way that works in all major browsers? (Chrome, Safari, Firefox and IE)? Thanks.
谁能告诉我是否有办法在客户端使用 Javascript 或 JQuery 进行 XML/XSLT 转换,这种方式适用于所有主要浏览器?(Chrome、Safari、Firefox 和 IE)?谢谢。
回答by Tom Davies
I should state from the start that I wrote this script, but if you're looking to just do some transformations and pass some parameters to your XSLT (nothing too fancy) then you can try Magic XML.
我应该从一开始就声明我编写了这个脚本,但是如果您只想进行一些转换并将一些参数传递给您的 XSLT(没什么特别的),那么您可以尝试Magic XML。
You can also have it automatically pull in your data and apply transformations by setting some data-
attributes on your DOM elements. For example...
您还可以通过data-
在 DOM 元素上设置一些属性,让它自动提取数据并应用转换。例如...
<div data-xml="example.xml" data-xslt="transform.xslt"></div>
...would automatically pull in data from example.xml and apply the transform.xslt to it.
...会自动从example.xml 中提取数据并将transform.xslt 应用到它。
It works in Opera, Chrome, Firefox and IE and is open source.
它适用于 Opera、Chrome、Firefox 和 IE,并且是开源的。
回答by Ian Roberts
回答by John
There's a client side example.
有一个客户端示例。