I have a problem. I have a SQL Server table that stores a bunch of XML documents in a column. I need to pass these XML documents to a XML parser, but the format of my starting XML is not in a format the parser can accept. Here’s what I have to work with –
XML stored in my SQL Server table is in the following format:
<Document ID="207">
<Version>1.0</Version>
<LastModifiedInVersion>1.0</LastModifiedInVersion>
<Signatures />
<Controls>
<Control ID="EmpID">
<Value>45678</Value>
</Control>
<Control ID="EmpFN">
<Value>Ryn</Value>
</Control>
<Control ID="EmpLN">
<Value>Veris</Value>
</Control>
<Control ID="EmpDOB">
<Value>01/19/1980</Value>
</Control>
</Controls>
<AutoKeys />
</Document>
I need to take that XML and make it look like this:
<xml_record>
<employee>
<EmpID value="45678"/>
<EmpFN value="Ryn"/>
<EmpLN value="Veris"/>
<empDOB value="01/19/1980"/>
</employee>
</xml_record>
I looked into using XSLT, but it seems to be all based around displaying XML data in a browser and not a translation of the actual format. My ultimate goal is simply to translate the format and use the XML parser to pull the employee values to populate another table, I don’t need any of the rest of the original XML. Is what I’m looking to do even possible? If so just pointing me in the right direction would be great.
Try this:
Not most elegant, but working.