Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    4

    Unanswered: ISSUE with NameSpace in SQL XML

    Will some one please update me why this query is not returning anything?


    declare @myDoc xml
    set @myDoc = '<ScreenState xmlns="shared" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Items>
    <ScreenStateItem>
    <Key>Tab</Key>
    <Value>0</Value>
    </ScreenStateItem>
    <ScreenStateItem>
    <Key>AllPortfolio</Key>
    <Value>True</Value>
    </ScreenStateItem>
    </Items>
    </ScreenState>'

    ;WITH XMLNAMESPACES ( DEFAULT 'http://www.w3.org/2001/XMLSchema-instance' )
    SELECT @myDoc.query('/ScreenState/Items/ScreenStateItem')

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    Welcome to the world of XML

    Code:
    ;WITH XMLNAMESPACES (
    	'http://www.w3.org/2001/XMLSchema-instance' as i,
    	default 'shared')
    SELECT @myDoc.query('/ScreenState/Items/ScreenStateItem')
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Jul 2011
    Posts
    4

    Thanks You!

    Appreciate your quick response.

  4. #4
    Join Date
    Jul 2011
    Posts
    4

    Another question on the same thread

    One more question on the same thread.

    How can I delete node "ScreenStateItem" when the internal node contains <Key>AllPortfolio</Key> in the xml below.

    Basically I wanted to get rid of parent node <ScreenStateItem> when child node <Key>AllPortfolio</Key> is found in it.

    <ScreenState xmlns="shared" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Items>
    <ScreenStateItem>
    <Key>Tab</Key>
    <Value>0</Value>
    </ScreenStateItem>
    <ScreenStateItem>
    <Key>AllPortfolio</Key>
    <Value>True</Value>
    </ScreenStateItem>
    </Items>
    </ScreenState>

Tags for this Thread

Posting Permissions

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