Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 convert an xml document from one format to another

Author  Topic 

ss2005variant
Starting Member

2 Posts

Posted - 2007-10-26 : 21:03:40
I need to convert the xml document below to another format also below. Can this be done in T-SQL? If so, how? The original xml doc is stored in a SS2005 table in with an XML datatype and is about 90,000 characters in this format, only the id names (measure id and element id) are changing.
--------------------
original xml:
--------------------
<submission xmlns="http://www.ncqa.org/ns/2006/idss/hedis">
<component type="GS">
<data>
<measures>
<measure id="aab">
<data-elements>
<data-element id="denominator"><value>3987</value></data-element>
<data-element id="numerator1"><value>536</value></data-element>
<data-element id="numerator2"><value>821</value></data-element>
</data-elements>
</measure>
<measure id="bcs">
<data-elements>
<data-element id="denominator"><value>4788</value></data-element>
<data-element id="numerator1"><value>987</value></data-element>
<data-element id="numerator2"><value>466</value></data-element>
<data-element id="numerator3"><value>516</value></data-element>
</data-elements>
</measure>
</measures>
</data>
</component>
</submission>
--------------------
The new format:
--------------------
<measures>
<aab>
<denominator>
<value>3987</value>
</denominator>
<numerator1>
<value>536</value>
</numerator1>
<numerator2>
<value>821</value>
</numerator2>
</aab>
<bcs>
<denominator>
<value>4788</value>
</denominator>
<numerator1>
<value>987</value>
</numerator1>
<numerator2>
<value>466</value>
</numerator2>
<numerator3>
<value>516</value>
</numerator3>
</bcs>
</measures>

Any help or advice would be much appreciated.

-Doug

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-10-28 : 23:49:22
xslt is commonly used to transform xml from one format to another. doing it in sql would be cumbersome.


elsasoft.org
Go to Top of Page
   

- Advertisement -