|
Home > Archive > MS SQL XML > September 2005 > Need help reading schema name from xml object
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Need help reading schema name from xml object
|
|
| MikePuyallup@hotmail.com 2005-09-16, 8:24 pm |
|
I want to have a stored proc that has an xml parameter. It would figure
out what to do with it based on what type of thing it is. I would like
to parse based on the schema. But I can't figure our how to use read
the schema out.
Example:
Declare @xml as xml
set @xml ='<?xml version="1.0"?><note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to test="please work">Bob</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Dont forget me this weekend!</body>
</note>'
select @xml.query('/@xmlns')
result
Msg 2390, Level 16, State 1, Line 15
XQuery [query()]: Top-level attribute nodes are not supported
Microsoft SQL Server Beta Edition 9.00.1116
| |
| Eugene Kogan [MSFT] 2005-09-16, 8:24 pm |
| Would namespace URI of the first top level element work for you?
select @xml.value('namespace-uri((/*)& #91;1])','nvarchar(1
000)')
Regards,
Eugene
---
This posting is provided "AS IS" with no warranties, and confers no rights.
< MikePuyallup@hotmail
.com> wrote in message
news:1126908599.385867.113230@g14g2000cwa.googlegroups.com...
>
> I want to have a stored proc that has an xml parameter. It would figure
> out what to do with it based on what type of thing it is. I would like
> to parse based on the schema. But I can't figure our how to use read
> the schema out.
>
>
> Example:
>
> Declare @xml as xml
> set @xml ='<?xml version="1.0"?><note
> xmlns="http://www.w3schools.com"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.w3schools.com note.xsd">
> <to test="please work">Bob</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Dont forget me this weekend!</body>
> </note>'
>
> select @xml.query('/@xmlns')
>
>
> result
>
> Msg 2390, Level 16, State 1, Line 15
> XQuery [query()]: Top-level attribute nodes are not supported
>
>
> Microsoft SQL Server Beta Edition 9.00.1116
>
|
|
|
|
|