Link to home
Create AccountLog in
Avatar of Desarrollo_Intelisis
Desarrollo_IntelisisFlag 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:Sample>
 <my:Name>Juan Perez</my:Name>
 <my:Address>Tehuantepec 2</my:Address>
 <my:Telephone>1234-5678</my:Telephone>
</my:Sample>


With this XML I try to do things like:
/****************************/
declare @idoc int
declare @doc varchar(1000)
set @doc ='
<my:Sample>
 <my:Name>Juan Perez</my:Name>
 <my:Address>Tehuantepec 2</my:Address>
 <my:Telephone>1234-5678</my:Telephone>
</my:Sample>'
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,

Carlos.
Login: Desarrollo_Intelisis
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer