DECLARE @ECAS XML;
SET @ECAS = '<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="ecasData" >
<xs:complexType>
<xs:all minOccurs="1" maxOccurs="1"/>
</xs:complexType>
</xs:element>';
SELECT @ECAS;
SQL Server XML DML Undeclared prefix
-
26-06-2022 - |
题
I can't understand why I get the error "XML parsing: line 2, character 45, undeclared prefix" in this simple line of code:
DECLARE @ECAS XML;
SET @ECAS = 'declare namespace xs="http://www.w3.org/2001/XMLSchema";
<xs:element name="ecasData">
<xs:complexType>
<xs:all minOccurs="1" maxOccurs="1"/>
</xs:complexType>
</xs:element>';
SELECT @ECAS;
Isn't declared the namespace xs in the begin of the sentence? Any help will be appreciated. Thanks.
解决方案
其他提示
In the interest of sanity, even though its not directly related to your code, and because this is a top googled post for "undeclared prefix", also look for xsi:nil="true"
in your xml
不隶属于 StackOverflow