2

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

Matt Felzani
  • 785
  • 10
  • 24

1 Answers1

2

Based on what you are saying you want a quick scrapbook to format XML files. Unfortunately the Display view or the Scrapbook Page file do not support code formatting. The quickest way is to have on the side (or on your Sandbox project) an XML 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.

Community
  • 1
  • 1
dimitrisli
  • 20,895
  • 12
  • 59
  • 63
  • yeah, i get that the link you referenced is the logic, i was more asking from the perspective of making it integrate with Eclipse. basically in the Display view i say `theXML.toString()` and it displays in the Console view. i want to be able to say `XMLUtil.prettyPrint(theXML)` and have the indented version of the string display in Console. – Matt Felzani Dec 14 '11 at 19:01