Re: Getting all nodes and node details from xml using xquery



Shilpa (shilpa.nagavara@xxxxxxxxxx) 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_preparedocument @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@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Nested Nodes in XML from a table
    ... > Thanks Erland, it works now. ... > extension, added the missing XML declaration line, SQL Server didn't ... > queries from SQL Server, but i rather create XML file and read from it ... but please look in Books Online. ...
    (comp.databases.ms-sqlserver)
  • Re: Help me with this query please.
    ... When I look at the examples for FOR XML EXPLICIT ... A more normal document would be: ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: XML as Linked Server?
    ... You could write a routine which runs the XML through XSLT and outputs CSV ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) ... I'd be able to view the XML data as a table and then ... >> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) ...
    (microsoft.public.sqlserver.dts)
  • Re: FOR XML not working in a subquery
    ... Why can't this be done in SQL Server 2000? ... have used extensively in SQL Server 2000--why the problem with FOR XML? ... Retrieving and Writing XML Data -> ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Help me with this query please.
    ... When I look at the examples for FOR XML EXPLICIT ... A more normal document would be: ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)