Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 XML processing

Author  Topic 

peddi_praveen
Starting Member

48 Posts

Posted - 2005-05-18 : 06:44:57
Hi all,
Following is the XML string which I'm trying to parse, but getting only the value of attribute. How can I display all the values associated with this?


declare @idoc int
declare @doc varchar(1000)
set @doc ='
<content>
<meta key="Testing Records" data-type="decimal">
<values>
<value>81023002</value>
<value>81023003</value>
<value>81112401</value>
</values>
</meta>
</content>'


EXEC sp_xml_preparedocument @idoc OUTPUT, @doc


SELECT *
FROM OPENXML (@idoc, '/content/meta/values',2)
WITH ([key] VARCHAR(100) '../@key',
value VARCHAR(1000) )

Expected output


Testing Records - 81023002
Testing Records - 81023003
Testing Records - 81112401


Praveen

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2005-05-18 : 07:26:44
Do you want something like this, then?

SELECT *
FROM OPENXML (@idoc, '/content/meta/values/value',2)
WITH ([key] VARCHAR(100) '../../@key',
value VARCHAR(1000) '.')

The XPath pattern that's the second parameter of OPENXML determines the cardinality of the result.
Go to Top of Page

peddi_praveen
Starting Member

48 Posts

Posted - 2005-05-19 : 01:28:59
Hi,
Exactly, We are looking for the same.

Tx alot.
regards,
Praveen
Go to Top of Page
   

- Advertisement -