有谁知道为什么这个
XML文本会在sql Server 2008中抛出非法的名字符错误?
原文链接:/xml/292530.html'<cs><c a="2" b="CITY & STATE TX" c="CITY & STATE TX"/></cs>'
异常消息是
Msg 9421,Level 16,State 1,Line 2 XML parsing: line 1,character 23,illegal name character
以下是用于解析此xml的查询
DECLARE @CaptionsDescriptions XML = '<cs><c a="2" b="CITY & STATE TX" c="CITY & STATE TX"/></cs>' DECLARE @DocHandle int DECLARE @CaptionsDescriptionsTable TABLE ( ID INT IDENTITY(1,1),languageID INT,Caption VARCHAR(50),Description VARCHAR(2000) ) EXEC sp_xml_preparedocument @DocHandle OUTPUT,@CaptionsDescriptions INSERT INTO @CaptionsDescriptionsTable SELECT a,b,c FROM OPENXML(@DocHandle,'cs/c') WITH ( a int,-- language id b varchar(50),-- caption c varchar(2000) -- description ) -- remove document handler EXEC sp_xml_removedocument @DocHandle
谢谢.