Avoid being called a bozo when producing xml


djQuickTip 2:06 AM on 28 Sep 2005

do you get many of your links from del.icio.us?

Pete 8:32 AM on 28 Sep 2005

The final advice in "Avoid adding pretty-printing white space in character data" seems pretty crazy to me. I guess it's legal XML but if the idea is to make the XML more readable it fails miserably. Better advice would have been to just don't do it and create a style sheet.

Ned Batchelder 9:32 AM on 28 Sep 2005

djQuickTip: No, I've never made del.icio.us part of my habitual routine. Why do you ask?

Ned Batchelder 9:34 AM on 28 Sep 2005

Pete: I agree with you. I've never seen XML formatted as he suggests. I've split an element across multiple lines, but the reason was to spread out its attributes so I could see them better, no so that the character content would be indented.

Sea McEligot 12:37 PM on 30 Sep 2005

There are alot of people out there who advocate a very bloated, combersome, do everything, XML world view. If you take this persons advices you will have an unmanageable nightmare. I suggest that you validate your XML, but make sure it's readable, and keep it simple. Don't use an XML library, do print.

Ned Batchelder 1:39 PM on 30 Sep 2005

Sean: I have to disagree: if you use print to create XML, you'll spend the rest of the lifetime of the product chasing down quoting bugs. Use a simple XML streamer.

Sea McEligot 2:55 PM on 30 Sep 2005

Well, yes, I do use, for example StringEscapeUtils.escapeXml from apache commons.

Fredrik 10:26 AM on 1 Oct 2005

If you find yourself having to explicitly escape stuff all the time, maybe you're printing the wrong things:


Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.