title: Convert Column XML data to Rows
body: <p>I am using version PostgreSQL 8.3.12.</p>
  
  <p>Table Column Name : xmltest</p>
  
  <p><code>id</code>   <code>data</code></p>
  
  <p><code>Data</code> Column contains XML data that looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ItemData&gt;
      &lt;ReviewComments&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
      &lt;/ReviewComments&gt;
      &lt;SmartTextData RootProtect="True"&gt;
          &lt;STI_Summary IID="d10c5cbf-f5cf-4478-9f33-4580c1930413" IR="True"&gt;
              &lt;ObjectValue /&gt;
              &lt;CP /&gt;
              &lt;SIProps ST="4" PL="False" PLS="" /&gt;
              &lt;STI_SummaryActiveProblemsField LIID="cdbd7044-ccde-11db-8cba-df0a56d89593" IID="37742a5f-7998-4715-8d43-0d7a19284d44" IR="True" RW="1"&gt;
              &lt;HD Title="Active Problems" /&gt;
              &lt;ObjectValue /&gt;
              &lt;CP&gt;
                  &lt;PosReplace /&gt;
                  &lt;NegReplace /&gt;
              &lt;/CP&gt;
              &lt;SIProps ST="4" PL="False" PLS="" /&gt;
              &lt;STI_US&gt;
                  &lt;ObjectValue&gt;
                      &lt;TextValue&gt;
                          &lt;![CDATA[
  ]]&gt;
                      &lt;/TextValue&gt;
                  &lt;/ObjectValue&gt;
                  &lt;CP /&gt;
                  &lt;SIProps ST="1" SS=" " PL="False" PLS="" /&gt;
              &lt;/STI_US&gt;
              &lt;STI_DxItem LIID="71194038-8ffb-488b-8af5-5f1f1a679115" IID="aaf2de4e-2f1f-409b-87b7-b7265bec37db" RW="1"&gt;
                  &lt;HD Title="Coronary artery disease  " /&gt;
                  &lt;ObjectValue&gt;
                      &lt;Code&gt;
                          &lt;CodingSystem&gt;ICD-9 CM&lt;/CodingSystem&gt;
                          &lt;Value&gt;414.01&lt;/Value&gt;
                      &lt;/Code&gt;
                      &lt;Code&gt;
                          &lt;CodingSystem&gt;SWICPC&lt;/CodingSystem&gt;
                          &lt;Value&gt;08.0.K76.CIR&lt;/Value&gt;
                      &lt;/Code&gt;
                  &lt;/ObjectValue&gt;
              &lt;/STI_DxItem &gt;
          &lt;/STI_Summary&gt;
      &lt;/SmartTextData&gt;
  &lt;/ItemData&gt;
  </code></pre>
  
  <p>I want to spilt XML Tag IID and CODE data to respective ID Column.</p>
  
  <p>Expected Output :</p>
  
  <pre><code>          ID   LIID                                         Code_Value   CodingSystem
            1    d10c5cbf-f5cf-4478-9f33-4580c1930413      NULL
            1    37742a5f-7998-4715-8d43-0d7a19284d44      NULL
            1    aaf2de4e-2f1f-409b-87b7-b7265bec37db      414.01         IC CM
            1    aaf2de4e-2f1f-409b-87b7-b7265bec37db      08.0.K76.CIR   SWICPC
  </code></pre>
  
  <p>Note : I am using version PostgreSQL 8.3.12 with this some new syntax of XMLPATH not work.</p>
  
  <p>Simply I want to convert XML Data to rows column structure.</p>
  
  <p>Thanks for Reading this.</p>