Sql-docs: “Inserting data using a CDATA section” has incorrect formatting

Created on 6 May 2020  Â·  4Comments  Â·  Source: MicrosoftDocs/sql-docs

The documentation tries to say that < is inserted as &lt; but it instead says that < is inserted as <.

The documentation’s example of the output XML also is invalid. It says the result is:

<Root>
<ProductDescription ProductID="1" ProductName="Road Bike">
<Features> <notxml> as text </notxml> or cdata </Features>
</ProductDescription>
</Root>

when the actual result is

<Root>
  <ProductDescription ProductID="1" ProductName="Road Bike">
    <Features> &lt;notxml&gt; as text &lt;/notxml&gt; or cdata </Features>
  </ProductDescription>
</Root>

Note that to get this result, the query I had to use was the following because I couldn’t figure out how to get the XPath to let me construct <![CDATA[…]]>. I am using SQL Server 11. Is support for direct construction of CDATA in expressions a relatively new feature?

DECLARE @myDoc XML = '<Root>
    <ProductDescription ProductID="1" ProductName="Road Bike">
        <Features/>
    </ProductDescription>
</Root>';
SELECT @myDoc;
DECLARE @x XML = N'<![CDATA[ <notxml> as text </notxml> or cdata ]]>';
SET @myDoc.modify('
insert sql:variable(''@x'')
into  (/Root/ProductDescription/Features)[1]
');
SELECT @myDoc;

Document Details

âš  Do not edit this section. It is required for docs.microsoft.com âžź GitHub issue linking.

Pri2 cba doc-bug sqprod t-sqtech

All 4 comments

@binki -- Nathan, thank you for your detailed feedback. I am looking into this article.

I reviewed private repo PR 14968 .
G

When will the changes be reflected in this repository? It still looks incorrect to me.

@binki We need to give the system a couple business days. As of now, the PR was merged less than two business days ago. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mverbaas picture mverbaas  Â·  3Comments

404
hfleitas picture hfleitas  Â·  3Comments

GeorgeTsiokos picture GeorgeTsiokos  Â·  4Comments

eliotg picture eliotg  Â·  3Comments

piotrek-k picture piotrek-k  Â·  3Comments