Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


XQuery Help


XQuery Help

Author
Message
david.tyler
david.tyler
SSC Veteran
SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)SSC Veteran (238 reputation)

Group: General Forum Members
Points: 238 Visits: 663
Hi fellow developers. I am new to XQuery and have an issue. Based on the following XML I can't get any results unless I remove the namespace information at the top. Is there anyway to ignore the namespace. I have tried the following:

TABLE:
/****** Object: Table [dbo].[Students] Script Date: 05/27/2010 14:57:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Students](
   [StudentName] [varchar](50) NULL,
   [Labid] [int] NULL,
   [Experimentid] [int] NULL,
   [ExperimentChemical] [xml] NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

---------------------------------------------------------------------------------
DATA:
INSERT INTO students
SELECT
   'ABC',
   3,
   3,
   '
   <ATOM xmlns="urn://valence.aero/schemas/airtransport/ATOM/300" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn://valence.aero/schemas/airtransport/ATOM/300 ATOM.300.00.xsd">
    <Destination>
      <Identity />
    </Destination>
    <Source>
      <Identity>
       <Organisation>qantas.com.au</Organisation>
       <Function>EI</Function>
       <Location>SYD</Location>
       <ProcessID>OgsAtomChangeNotification</ProcessID>
      </Identity>
      <GenerationTime>2010-05-24T11:14:08.355+10:00</GenerationTime>
    </Source>
   </ATOM>
   '

---------------------------------------------------------------------------------
QUERY:
SELECT *
FROM students
WHERE experimentchemical.exist('/ATOM/Source/Identity[Location="SYD"]') = 1

ALSO TRIED:
SELECT *
FROM students
WHERE experimentchemical.exist('//Source/Identity[Location="SYD"]') = 1
seth delconte
seth delconte
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1627 Visits: 1360
I know this question is 2 years old, but thought I would answer it anyway.

I don't think you can 'ignore' the namespace, and your best bet may be to use a WITH XMLNAMESPACES clause:

SET ANSI_PADDING ON
GO
;WITH XMLNAMESPACES ('urn://valence.aero/schemas/airtransport/ATOM/300' AS ns)
SELECT *
FROM students
WHERE experimentchemical.exist('/ns:ATOM/ns:Source/ns:Identity[ns:Location="SYD"]') = 1



_________________________________
seth delconte
http://sqlkeys.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search