Desarrollo_Intelisis
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</m y:Telephon e>
</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</m y:Telephon e>
</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
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</m
</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</m
</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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.