{"id":345,"date":"2013-06-28T11:01:39","date_gmt":"2013-06-28T18:01:39","guid":{"rendered":"http:\/\/www.milow.net\/public\/?p=345"},"modified":"2021-05-01T06:52:59","modified_gmt":"2021-05-01T13:52:59","slug":"eclipse-tips-debugging-xml","status":"publish","type":"post","link":"https:\/\/www.milow.net\/public\/techblog\/eclipse-tips-debugging-xml.html","title":{"rendered":"Eclipse Tips: Debugging XML"},"content":{"rendered":"<p>When using <a href=\"http:\/\/dom4j.sourceforge.net\/\">dom4j<\/a> objects in <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a>, it is sometimes hard to determine what the contents of a particular Document or Element are:<\/p>\n<div style=\"margin-left:50px\">\n<div class=\"nolink\"><a title=\"no formatting\" rel=\"lightbox[1]\" href=\"\/site\/images\/techblog\/eclipse1_origxml.png\"> <img decoding=\"async\" style=\"width:388px;height:120px\" src=\"\/site\/images\/techblog\/eclipse1_origxml.png\" alt=\"\" \/><\/a>\n<\/div>\n<\/div\n\nEclipse has a really great formatting feature that allows you to use Java code to format what Eclipse shows you when looking at variables. To use it for Dom4j objects, do the following:\n\n\n\n<li style=\"font-size:12px\">Step into code that uses an Element, Document, etc<\/li>\n<li style=\"font-size:12px\">Open the Variables view, right click on the object, and select &#8220;New Detail Formatter&#8221;:<\/li>\n<div style=\"margin-left:50px\">\n<div class=\"nolink\"><a title=\"menu option\" rel=\"lightbox[1]\" href=\"\/site\/images\/techblog\/eclipse1_formattermenu.png\"> <img decoding=\"async\" style=\"width:453px;height:297px\" src=\"\/site\/images\/techblog\/eclipse1_formattermenu.png\" alt=\"\" \/><\/a>\n<\/div>\n<\/div>\n<li style=\"font-size:12px\">Enter the following code:<\/li>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\njava.io.StringWriter sw = new java.io.StringWriter(); \r\norg.dom4j.io.OutputFormat format = org.dom4j.io.OutputFormat.createPrettyPrint(); \r\norg.dom4j.io.XMLWriter writer = new org.dom4j.io.XMLWriter( sw, format ); \r\nwriter.write(this); \r\nreturn sw.toString();\r\n<\/pre>\n<li style=\"font-size:12px\">Click OK. You will now see a more readable format for your Dom4j objects:<\/li>\n<div style=\"margin-left:50px\">\n<div class=\"nolink\"><a title=\"with formatting\" rel=\"lightbox[1]\" href=\"\/site\/images\/techblog\/eclipse1_afterformat.png\"> <img decoding=\"async\" style=\"width:379px;height:120px\" src=\"\/site\/images\/techblog\/eclipse1_afterformat.png\" alt=\"\" \/><\/a>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>When using dom4j objects in Eclipse, it is sometimes hard to determine what the contents of a particular Document or Element are:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/posts\/345"}],"collection":[{"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":19,"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":737,"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/posts\/345\/revisions\/737"}],"wp:attachment":[{"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milow.net\/public\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}