+ Reply to Thread
Results 1 to 2 of 2

Thread: Xpath Query

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    34

    Xpath Query

    I have that piece of code :
    Code:
    <Something xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Id xmlns="http://something.com/">1921</Id>
      <Date xmlns="http://something.com/">1901-01-01T00:00:00Z</Date>
      <Schedule xmlns="http://something.com/">Region</Schedule>
      <Filters xmlns="http://something.com/">
        <Data>
          <Id>99999</Id>
          <Name>CS</Name>
          <Type>SomeType</Type>
        </Data>
      </Filters>
    </Something>
    And i would like select the value of Type where the xml below is in an xml typed column in a table

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    35
    You can try :
    Code:
    ;WITH XMLNAMESPACES ('http://something.com/' AS xn)
    SELECT
        XmlType = XmlColumn.value('(Something/xn:Filters/xn:Data/xn:Type)[1]', 'varchar(50)') 
    FROM 
        dbo.Tablename
    Last edited by alias; 01-26-2012 at 04:25 PM.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts