CDATA Section means nothing? You should read this post

This is super simple but amazingly few developers know CDATA exists. About a year ago I asked Burr Sutter what was all this CDATA garbage in messages we were receiving from an (IBM) MQ feed. He told me and I was stunned I had never heard of it before, I soon said “wow that’ll make my XML driven interface so much easier in terms of having readable XML”. The XML in question was full of &lt; for < and &gt; for > – in some cases I was storing XML inside XML and that can get messy! Take a look at the little example below.. pretty sweet eh?

  <HardToEncodeString>Paul Lockwood” &lt;;</HardToEncodeString>
  <EasyToEncodeString><![CDATA[“Paul Lockwood” <>]]></EasyToEncodeString>

This is why contracting rules – there are always fresh faces to learn from. Last night it dawned on me that casting a working ArrayList to an array [via ToArray(typeof)]  after parsing an input message/ config file is better than my usual ‘smart’ approach of creating a strongly typed collection (assuming you are only reading the data). A Thoughtmill guy educated me there – a few months back the use of Factories really clicked thanks to an Innovative Architects employee. Now should I feel stupid or educated?

This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to CDATA Section means nothing? You should read this post

  1. Jeffrey says:

    "Now should I feel stupid or educated?"

    Hmm… 🙂 I’ve been using CDATA since as far as I can remember. I build my first XML driven site 5 years ago and used CDATA back then to encapsulate raw data that I had no control over. This, I believe, is the reason for it’s existence. Anytime I have to use data that is user controlled I wrap it CDATA to be safe 🙂

  2. Paul L says:

    Thanks Jeffery, I’ll keep watching your Blog to see what other basic knowledge I am missing. In September obviously, this break from reading Blogs is quite relaxing 🙂

  3. Jeffrey says:

    LOL… yeah, I excel in basic knowledge… hehe. Taking breaks for blogs is a good thing for sure. Nothing like feeling forced to read them or write in them to make you sick and tired of them 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s