我正在尝试在数据库中插入 xml 文件,但我在输入的开头没有收到此错误 text/xmldecl。
这是查询:
INSERT [EMR].[tblTemplateForm]
(FormXML)
VALUES ( CAST('<?xml version="1.0" encoding="UTF-8"?><EMR>
<CustomTextBox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Text>0.0</Text>
<Type>TextBox</Type>
<Width>300</Width>
<id>txt1</id>
<Label>POG(LMP)</Label>
<LabelWidth>200</LabelWidth>
<labelFontStyle>normal</labelFontStyle>
<labelFontWeight>normal</labelFontWeight>
<labelFontColor>Black</labelFontColor>
<CaptionOrientation>Horizontal</CaptionOrientation>
<NewControl>false</NewControl>
<NumericText>0</NumericText>
<TextMode>Singleline</TextMode>
<rows>0</rows>
<columns>0</columns>
</CustomTextBox><?xml version="1.0"?>
<CustomNumericTextBox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Type>NumericTxtBox</Type>
<Width>500</Width>
<id>numTxt1</id>
<Label>numTxt1</Label>
<LabelWidth>200</LabelWidth>
<labelFontStyle>normal</labelFontStyle>
<labelFontWeight>normal</labelFontWeight>
<labelFontColor>Black</labelFontColor>
<CaptionOrientation>Horizontal</CaptionOrientation>
<NewControl>false</NewControl>
<NumericText>3</NumericText>
</CustomNumericTextBox><?xml version="1.0"?>
<AllControlsCount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Width>0</Width>
<id>ControlsID</id>
<LabelWidth>0</LabelWidth>
<NewControl>false</NewControl>
<NumericText>0</NumericText>
<lblCount>0</lblCount>
<txtCount>12</txtCount>
<numTxtCount>1</numTxtCount>
<ddlCount>0</ddlCount>
<rbCount>0</rbCount>
<cbCount>0</cbCount>
</AllControlsCount>
</EMR>' as XML))
GO
错误信息:
Msg 9438, Level 16, State 1, Line 1
XML parsing: line 19, character 24, text/xmldecl not at the beginning of input
表结构:
TABLE [EMR].[tblTemplateForm](
[FormID] [int] IDENTITY(1,1) NOT NULL,
[FormName] [varchar](100) NULL,
[FormDesc] [varchar](255) NULL,
[FormXML] [xml] NULL,
[Published] [bit] NULL,
[FormType] [int] NULL,
[CreatedID] [int] NULL,
[CreatedDate] [datetime] NULL,
[ModifiedID] [int] NULL,
[ModifiedDate] [datetime] NULL,