Il blog di Emanuele Mattei in ambito Database

Programmazione database, ado.net e database mobile

Blog

Siti

Siti Sql Server

Siti vari

Tools

Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1 The error description is 'The character '<' cannot be used in an attribute value.'.

Quando si usa la Stored procedure sp_xml_preparedocument si può verficare un errore durante l'inserimento dei dati, qualora si sta inserendo un valore di tipo xml. Per ovviare a tale problema, utilizzare i codici html per i simboli < (&lt;) o > (&gt;).

Qui di seguito si riporta un esempio di script

DECLARE @xmlDocument nvarchar(max)

SET @xmlDocument = N'<ROOT>

<TBL_xml Nome="EMa" data="11/12/2009" Codexml="&lt;a&gt;prova&lt;/a&gt;" code="2" cognome="Ma">

</TBL_xml>

</ROOT>'

DECLARE @punt INT

EXEC sp_xml_preparedocument @punt OUTPUT, @xmlDocument

INSERT TBL_xml

SELECT *

FROM OPENXML(@punt, N'/ROOT/TBL_xml')

WITH TBL_xml

Select * from tbl_xml

   

Posted: feb 09 2009, 03.21 by EmanueleM | with no comments
Filed under: