|
Home > Archive > Microsoft SQL Server forum > April 2006 > Getting all nodes and node details from xml using xquery
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 |
Getting all nodes and node details from xml using xquery
|
|
| Shilpa 2006-04-06, 7:33 am |
| Hi,
I haev the following code:
DECLARE @x xml
SET @x='
<Root>
<row id="1"><name>Larry</name><oflw>some text</oflw></row>
<row id="2"><name>Joe</name></row>
<row id="3" />
</Root>
'
exec sp_xml_preparedocume
nt @idoc OUTPUT, @x
SELECT * FROM OPENXML(@idoc, '/Root')
This gives the following details
id
parentid
nodetype localname
prefix
namespaceuri
datatype
prev text
I want to get the same details using XQuery, please let me know how to
go about it.
Regards,
Shilpa
| |
| Erland Sommarskog 2006-04-08, 7:26 am |
| Shilpa (shilpa.nagavara@unisys.com) writes:
> I haev the following code:
>
> DECLARE @x xml
> SET @x='
><Root>
> <row id="1"><name>Larry</name><oflw>some text</oflw></row>
> <row id="2"><name>Joe</name></row>
> <row id="3" />
></Root>
> '
> exec sp_xml_preparedocume
nt @idoc OUTPUT, @x
> SELECT * FROM OPENXML(@idoc, '/Root')
>...
> I want to get the same details using XQuery, please let me know how to
> go about it.
I am not sure that you can to this easily. You use a very special form
of OPENXML, the one without a WITH clause, that gives you an edge table.
I have never found any use for edge tables, but maybe I've overlooked
something.
Since I'm no specialist in XML, I've consulted my MVP colleagues who know
this topic better, so hopefully I will be able to return with a more
definitive answer.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
|
|
|
|
|