Avatar of Desarrollo_Intelisis
Flag for Mexico

asked on 

Problems with undeclared namespace prefix

Hi Experts!

I'm working with Windows XP Professional Version 2002 Service Pack 2 and MSSQL version 8.

An external application gives me an XML like this one:

 <my:Name>Juan Perez</my:Name>
 <my:Address>Tehuantepec 2</my:Address>

With this XML I try to do things like:
declare @idoc int
declare @doc varchar(1000)
set @doc ='
 <my:Name>Juan Perez</my:Name>
 <my:Address>Tehuantepec 2</my:Address>
exec sp_xml_preparedocument @idoc OUTPUT, @doc

SELECT * FROM  OPENXML (@idoc, '/my:Sample') WITH (Dato varchar(100) 'my:Address')

EXEC sp_xml_removedocument @idoc

When I execute this instructions in the QueryAnalyzer the result is:

Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedocument, Line 9
XML parsing error: Reference to undeclared namespace prefix: 'my'.  

If I change ":" by "_" or by "." in all of "my:" of the XML, it works perfectly.

*** What can I do to avoid to have to replace whenever information with this format arrives to me?

*** Why with ":" it doesn't work and with "." (or "_") it does?

** What is the meaning of "undeclared namespace prefix: 'my'"?

Thank you very much in advance,

Login: Desarrollo_Intelisis
Web Languages and StandardsMicrosoft SQL Server

Avatar of undefined
Last Comment
Anthony Perkins

8/22/2022 - Mon