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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PerkinsCommented:
>>What is the meaning of "undeclared namespace prefix: 'my'"?<<
It probably means you have to declare the namespace.  As in take a look at the syntax for sp_Xml_PrepareDocument in BOL:

sp_xml_preparedocument hdoc OUTPUT [, xmltext] [, xpath_namespaces]

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.