我正在尝试在数据库中插入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,
答案 0 :(得分:7)
重复XML声明
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0"?>
<?xml version="1.0"?>
如果包含XML声明,它必须位于XML文档第一行的第一个位置
答案 1 :(得分:3)
为什么你有额外的
<?xml version="1.0"?>
在两个地方?删除它们,它应该工作正常。
拉吉