473,434 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Getting all nodes and node details from xml using xquery

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_preparedocument @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

Apr 6 '06 #1
2 2828
Shilpa (sh*************@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_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, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Apr 8 '06 #2
"Shilpa" <sh*************@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_preparedocument @idoc OUTPUT, @x
SELECT * FROM OPENXML(@idoc, '/Root')

This gives the following details
id
parentid
nodetype localname

prefix

namespaceuri
datatype

prev text

I inquired about this, and you can only get localname, namespace URI
and the node's value with XQuery. You cannot get the positional node
information or node ids or prefixes.

For an example, look up the newsgroup microsoft.public.sqlserver.xml.
Michael Rys, who is the Program Manager for XML in SQL Server, and
whom I got this information from, says he recently posted an example
to that group.

--
Erland Sommarskog, Stockholm, es****@sommarskog.se

Apr 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Xamle Eng | last post by:
One of the things I find most unnatural about most XML APIs is that they try to abstract both elements and text into some kind of "node" object when they have virtually nothing in common. The...
2
by: arvindsd | last post by:
Hi all, The code below gets me a list of all the nodes within the node object called xml_tags_root. NodeList nl = xml_tags_root.getChildNodes(); The length of nodelist I get is double the...
7
by: F. Da Costa | last post by:
Hi, I' looking to retrieve ProdName1 form the <tr> below. <tr id="1-1-1" class="even"> <td> <div class="tier4"> <a href="#" class="leaf"></a> ProdName1 </div>
4
by: leodippolito | last post by:
Hello sirs, I am trying to send a POST request to a webservice on the click of a button. This will return me an XML document with a list of combo box items. The problem: in FIREFOX, when the...
2
by: Saurabh Sharma | last post by:
Hi, I am using Dom Parsing in Xml. I am the parent node and it has many children and each children has many children. I want to select children with a given name . Is there any method by which we...
6
by: jw | last post by:
hi all,i have such 2 classes for a linked list, class Node{ private: int value; Node *next; public: Node() { next=NULL; }
2
by: Kristopher Wragg | last post by:
I'm having some serious problems with the TreeView control. I've got a control that inherits TreeView and has some methods that firstly create a TreeNode then does some recursive procedure to add...
4
by: Pim75 | last post by:
Hello, I have to read a XML file in ASP and save the values in a database. I can get this work, but I cannot read some nested nodes of the xml file. This is a part of the XML file: ...
1
by: Tom | last post by:
Hey, I have a treeview control which i am reading and writing slots to (Its a player manager for Delta Force Black Hawk Down). At the moment, every 100ms it reads through the games memory to...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.