从显示视图在 Eclipse 控制台中漂亮打印 XML
我有一个对象,可以在调试期间从中获取字符串。该字符串是有效的 XML,但它“还算漂亮”(假设它在“XML 热度等级”上只是 10 分中的 6 分),因为它的每个节点都在自己的行上,但文本没有缩进。
我想知道是否有人知道一种简单的方法来使用 Eclipse 中显示视图可用的工具,以便当我将该字符串写入控制台视图时它可以正确缩进?
或者,如果有人可以指导我如何使该方法可在“显示”视图中使用,我可以自己编写一个简单的静态方法来执行此操作。
提前致谢!
-马特
I have an object that I can get a String from during debugging. That string is valid XML, but it's "half pretty" (let's say it's just a 6 out of 10 on the "XML Hotness Scale") in that it has each node on its own line, but the text isn't indented.
I was wondering if anyone knew of an easy way to use the tools available to the Display view in Eclipse so that when I write that string to the Console view it's properly indented?
Or I can write a thin static method on my own to do it if someone can guide me as to how to make that method available for use in the Display view.
Thanks in advance!
-Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的说法,您需要一个快速剪贴簿来格式化 XML 文件。遗憾的是,
Display
视图或Scrapbook Page
文件不支持代码格式。最快的方法是在侧面(或在您的 Sandbox 项目上)创建一个XML
文件,您可以在其中粘贴未格式化的 XML,然后按 Ctrl + A 选择所有内容,使用 Ctrl + Shift + F 美化 XML。如果您想以编程方式执行此操作,请查看此答案。
Based on what you are saying you want a quick scrapbook to format XML files. Unfortunately the
Display
view or theScrapbook Page
file do not support code formatting. The quickest way is to have on the side (or on your Sandbox project) anXML
file where you would paste your unformatted XML, then you hit Ctrl + A to select everything and Ctrl + Shift + F to beautify your XML.If you want to do that programatically have a look at this answer.