Thursday, June 18, 2009

MS SQl + XML parsing error: Reference to undeclared namespace prefix

When a namespace is declared in your xml document / String and you will use the OpenXml in your stored Procedure / Sql Query, you will get this type of error. To remove this error you need to define the namespace while you write the EXECUTE statement in you query/stored procedure.

Suppose you have written the following statement:

EXEC sp_xml_preparedocument @docHandle OUTPUT, @XmlDoc

So you need to change it with the following one:

EXEC sp_xml_preparedocument @docHandle OUTPUT, @XmlDoc, ‘

Where ns0 is the namespace of your xmlDocument, which is defined in the first node of your xml document. Suppose my xml document is as follows:


ID_0
Name_0

Address_0

City_0

Let me know if you have any query:)

Regards,

Vijay Modi

No comments:

Post a Comment