0

I need to convert some semistructured data into a SQL command. Let's say I need to transform this XML:

 <Data>
     <ID>1</ID>
     <Code>Test</Code>
     <SomeData><AnythingCanBeHere /></SomeData>
 </Data>

into this text:

 INSERT SomeTable (ID, Code, SomeData)
 VALUES (1, 'Test', '<SomeData><AnythingCanBeHere /></SomeData>');

I have output method set to text: I'm having hard time to get the SomeData element with anything in it to the ouput.

I found simmilar question, but the answer suggests to set output method to XML, which is a bit weird :-) Any other ideas?

Thanks

Community
  • 1
  • 1
  • I am not sure what your question is. There are two answers in the other question you linked to, and either one of them will work. – michael.hor257k Sep 18 '14 at 05:56
  • @michael.hor257k: First answer sets the output method to XML, but the output is pure text. The second answer expects I know the structure of the "SomeData" element, but I don't, it can be anything. – Jaroslav Bačkora Sep 18 '14 at 06:05
  • The output of the answer that uses `XML` as the output method is not text. It's an XML fragment that may contain text nodes - even free-standing text nodes. Why do have a problem with that? – michael.hor257k Sep 18 '14 at 06:11
  • OK, I'll use it :-) But still I'm wondering if it is possible to achieve this with method set to text? – Jaroslav Bačkora Sep 18 '14 at 06:24
  • It's possible, but quite laborious and error-prone to do yourself - see the links here: http://stackoverflow.com/questions/11733618/opposite-method-to-disable-output-escaping-in-xslt/ – michael.hor257k Sep 18 '14 at 06:44

0 Answers0