Posts mit dem Label miscellaneous werden angezeigt. Alle Posts anzeigen
Posts mit dem Label miscellaneous werden angezeigt. Alle Posts anzeigen

Freitag, 16. März 2012

pretty format a xml string

do you get most of the time xml not in a human readable format?

this snippet can help:
private String formatXml(String xml) {
        try {
            Transformer serializer = SAXTransformerFactory.newInstance().newTransformer();
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
            Source xmlSource = new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes())));
            StreamResult res = new StreamResult(new ByteArrayOutputStream());
            serializer.transform(xmlSource, res);
            return new String(((ByteArrayOutputStream) res.getOutputStream()).toByteArray());
        } catch (Exception e) {
            return xml;
        }
    }

Donnerstag, 15. März 2012

Try to write more - promise

Hi all

I know I stopped writing last year in April.

I try to write now more constantly! Promise! :-)

Montag, 18. April 2011

Java Black Belt

Regarding my last articel [Coding Kata] you would also like to take some java exams.

Check out the exams from Java Black Belt.

http://www.blackbeltfactory.com/

It's free.

Freitag, 15. April 2011

Coding Kata

I work colleague showed me this side:

http://codingkata.org/

the Idea behind: "small exercises to improve your programming skills"

I will give it a try