Parse XML in SQL procedure

parse xml in sql
parse xml in sql

Handle special character in XSLT

The combination of xml and XSLT is great. I personally like to use it in all my projects . Its working great . Use of xslt helps to reduce development and time and super in maintainability .

In general screnario, we have a xml document which has some node and value . We write a xslt to transform it into some other format (xml,html ). This works great till the time it does not meet the real devil..

 I  have written a simple xslt for it

<?xml version=”1.0″ encoding=”UTF-8″?>

<xsl:stylesheet version=”1.0″ xmlns:xsl=”“>
<xsl:output method=”html”/>
<xsl:template match=”/”>
    <table border=”1″>
      <tr bgcolor=”Blue”>
        <th>Company Name</th>
      <xsl:for-each select=”catalog/Rec”>
         <xsl:value-of select=”CompanyName”/>


and I have a simple below mentioned xml

<?xml version=”1.0″ encoding=”utf-8″?>

  <CompanyName>A B</CompanyName>
  <CompanyName>C & D</CompanyName>

Now if we run this transformation by addingxml-stylesheet type=”text/xsl” href=”test.xslt”?>

This will crash my xslt .


Replace CompanyName  tas as   < ! [ CDATA[ C &D ]]>

Thats it !!

Add intelligence to your dumb XML document

In todays advance application development , everyone want things easier , faster , reliable . In this case Intelligence in the various IDE’s are playing a major  role. Just  imagine you go to the office and start your Visual Studio IDE ( for example) and you have a lot to finish by end of the day …  and oops .. some how  today your IDE is little angry with you and it has stopped its  intelligence services for you (just for one day 😉  )

At this point we are kinda  helpless , off course it  doesn’t  mean that we cannot proceed with out work but off courseit will take a little bit  extra time and most of the times there will be more syntactical errors too.. and imagine if you have to make xml document…. 

So today i have decided to write this post about how you can make your xml document intelligent ..This is off course not a rocket science but it’s just  works  great.

So here we  go ::::::

(1) I have created a new web application project in my favourite IDE VS2008 .

(2) Now add an empty excel document to your solution .

(3) Open this document and see there is no intelligence . it would be really nice if i know in advance (with the help of intelligence) what all possible node i have to enter in this document . Offcourse  in most of the cases  we have a schema  for all XML docs . So   right-click on your xml document and set the Schema property by browsing a respective schema for this xml document .


Here, in this example i am adding the configuration schema for  Nhibernate , and voilaaaa….  Now my dumb xml document has  become smart and i have the intelligence..


Hope this will help 🙂