NodeTable_To_Xml
Constructs an XML from tabular data
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.NodeTable_To_Xml()
This procedure requires the SQLHTTP.net.NodeTable to be populated which is normally populated via the Xml_To_NodeTable stored procedure.
xml
This function is intended for users who wish to avoid using XPath syntax. It is not very efficient and only intended for infrequent simple Xml updates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
BEGIN TRAN DECLARE @X xml SET @X = '<?xml version="1.0" encoding="UTF-8"?> <DocumentElement param="value"> <FirstElement> ¶ Some Text </FirstElement> <?some_pi some_attr="some_value"?> <SecondElement param2="something"> Pre-Text <Inline>Inlined text</Inline> Post-text. </SecondElement> </DocumentElement>' DELETE SQLHTTP.net.NodeTable INSERT INTO SQLHTTP.net.NodeTable SELECT * FROM SQLHTTP.net.Xml_To_NodeTable(@X) UPDATE SQLHTTP.net.NodeTable SET [Value] = 'THIS TEXT IS NEW!!!' WHERE NodePath = 'DocumentElement/SecondElement/Inline' SELECT SQLHTTP.net.NodeTable_To_Xml() DELETE SQLHTTP.net.NodeTable COMMIT TRAN |
1 2 3 4 5 6 7 8 9 10 11 |
<DocumentElement param="value"> <?some_pi some_attr="some_value"?> <FirstElement> &#182; Some Text </FirstElement> <SecondElement param2="something"> Pre-Text <Inline>THIS TEXT IS NEW!!!</Inline> Post-text. </SecondElement> </DocumentElement> |