Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2006, 05:56 AM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default OPENXML

Can anyone help me?.I am running this script but it does not give any result.

declare @doc varchar(8000)
select @doc ='
<?xml version="1.0" encoding="utf-8" ?>
<UTSv_ProviderAvailRS xmlns="http://www.eviivo.com/UTSv/2004/01/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eviivo.com/UTSv/2004/01/01/UTSv_ProviderAvailRS.xsd" TimeStamp="2004-08-17T09:30:47-05:00" Target="Production">
<ProductProviders>
  <ProductProvider ID="DMS_PROV_ID_1" SpecialOffer="true" />
  <ProductProvider ID="DMS_PROV_ID_2" Package="true" />
  </ProductProviders>
  </UTSv_ProviderAvailRS>'
--Create an internal representation of the XML document.
exec sp_xml_preparedocument @idoc OUTPUT, @doc
-- SELECT stmt using OPENXML rowset provider
SELECT *
FROM OPENXML (@idoc, '/UTSv_ProviderAvailRS/ProductProviders/ProductProvider',2)
         WITH (ID varchar(30) '@ID'
          ,SpecialOffer varchar(30) '@SpecialOffer'
              ,Package varchar(30) '@Package'
             )

 
Old May 5th, 2006, 06:13 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I suggest you read up on namespaces:

http://www.dpawson.co.uk/xsl/sect2/N5536.html

especially numbers 13 and 23.

Then take a look at this:

http://www.sqlxml.org/faqs.aspx?faq=66

it shows how to declare a namespace prefix mapping with OPENXML.



--

Joe (Microsoft MVP - XML)









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.