在 Firefox 中更好地查看 XML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/972914/
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
Better XML viewing in Firefox
提问by dirtside
When you view a simple XML document in Firefox, it goes to the standard XML display mode, where you can collapse subtrees, etc. But it's pretty limited in functionality; there's nothing convenient like "expand all" and "collapse all" buttons, there's that annoying "This XML file does not appear to have any style information associated with it. The document tree is shown below" message at the top of the page. Are there any decent Firefox extensions that provide better XML viewing/manipulating/navigating? I looked in the Mozilla extension repository but there didn't seem to be anything promising.
当您在 Firefox 中查看一个简单的 XML 文档时,它会进入标准的 XML 显示模式,您可以在其中折叠子树等。但是它的功能非常有限;没有什么像“全部展开”和“全部折叠”按钮那样方便,页面顶部有令人讨厌的“此 XML 文件似乎没有任何与其相关的样式信息。文档树如下所示”消息。是否有任何不错的 Firefox 扩展可以提供更好的 XML 查看/操作/导航?我查看了 Mozilla 扩展存储库,但似乎没有任何希望。
回答by wmitchell
You can edit firefox's own xsl doc as indicated by the following link
您可以按照以下链接的指示编辑 firefox 自己的 xsl 文档
I'm after the same kind of thing myself i'll have a play with xsl and post my results.
我自己也在做同样的事情,我会玩一下 xsl 并发布我的结果。
回答by Pierre
You can associate an XSLT Stylesheet to your XML document by adding :
您可以通过添加以下内容将 XSLT 样式表关联到您的 XML 文档:
<?xml-stylesheet type="text/xsl" encoding="UTF-8" href="yourstylesheet.xsl" version="1.0"?>
after the XML declaration. See http://www.w3schools.com/xsl/xsl_transformation.aspfor more information.
在 XML 声明之后。有关更多信息,请参阅http://www.w3schools.com/xsl/xsl_transformation.asp。
回答by Nat
When I write web services that serve XML content, I usually prepend an XML stylesheet declaration to the content to style the content for human consumption. The stylesheet is a client-side XSLT transform that runs in the browser to turn the XML into XHTML and CSS, maybe with some JavaScript to add interactivity. It makes it much easier to debug the webservice and often means I don't have to write an HTML webapp to access the same data.
当我编写提供 XML 内容的 Web 服务时,我通常在内容前面添加一个 XML 样式表声明,以设置供人类消费的内容样式。样式表是一个客户端 XSLT 转换,它在浏览器中运行以将 XML 转换为 XHTML 和 CSS,可能还使用一些 JavaScript 来增加交互性。它使调试网络服务变得更加容易,并且通常意味着我不必编写 HTML 网络应用程序来访问相同的数据。
回答by SpliFF
Associate another viewer with the XML mimetypes you want to edit by editing mimeTypes.rdfin your profile directory. XML is application/xml and text/xml but there are also specific variants like application/xhtml+xml, application/svg+xml and application/rss+xml that'll you'll need to decide whether to override the default behaviour (catching these would break XHTML rendering, SVG images and RSS feeds respectively).
通过编辑配置文件目录中的mimeTypes.rdf,将另一个查看器与您要编辑的 XML mimetypes 相关联。XML 是 application/xml 和 text/xml 但也有特定的变体,如 application/xhtml+xml、application/svg+xml 和 application/rss+xml,您需要决定是否覆盖默认行为(捕获这些将分别破坏 XHTML 渲染、SVG 图像和 RSS 提要)。
Once you've registered the type you should be able to modify the default action under Tools->Options / Applications to use whatever editor you want.
一旦您注册了类型,您应该能够修改工具->选项/应用程序下的默认操作以使用您想要的任何编辑器。
回答by user
This is more a hack than a solution, but you can open Firefox Developer Tools and browse an XML there.
这与其说是解决方案,不如说是一种技巧,但您可以打开 Firefox 开发人员工具并在那里浏览 XML。
Actually currently it's not much better than the normal view, but at least it has all nodes collapsed from start and you can Alt+click to expand all descendants of a node (since Firefox 31).
实际上目前它并不比普通视图好多少,但至少它从一开始就折叠了所有节点,您可以按 Alt+单击来展开节点的所有后代(自 Firefox 31 起)。
回答by Deepak.Aggrawal
You can add developer toolbar that allows XML Developer's use of standard tools all from your browser!
您可以添加开发人员工具栏,允许 XML 开发人员在您的浏览器中使用标准工具!
https://addons.mozilla.org/en-us/firefox/addon/xml-developer-toolbar/
https://addons.mozilla.org/en-us/firefox/addon/xml-developer-toolbar/
回答by Andrew B
This extension is pretty good:
这个扩展非常好:
https://addons.mozilla.org/en-US/firefox/addon/xmlutils/
https://addons.mozilla.org/en-US/firefox/addon/xmlutils/
Adds a nicer font and includes xPath evaluation.
添加更好的字体并包括 xPath 评估。
回答by Cameron
Nat, this doesn't help if you're downloading someone else's XML content.
Nat,如果您正在下载其他人的 XML 内容,这无济于事。
I usually use IE 6 (at least you can open it in a text editor), but IE8 acts similarly to Firefox. I'd love an answer to this question.
我通常使用 IE 6(至少你可以在文本编辑器中打开它),但 IE8 的行为与 Firefox 类似。我很想回答这个问题。

