• Thom A - Thursday, November 16, 2017 8:47 AM

    I have to agree with Steve, I'm not a fan of XQuery. I (normally) have to look up the syntax each and every time I have to use it.

    To the OP, this might get you on the right path.  I'm not quite sure what you want as your WHERE, but the syntax to get you on track is there:

    CREATE TABLE #XML (XMLData xml);
    INSERT INTO #XML
    VALUES (
    '<SelectedValues>
    <SelectedValue>
      <Name>UPC</Name>
      <Value>Test10</Value>
    </SelectedValue>
    <SelectedValue>
      <Name>Brand</Name>
      <Value>HP</Value>
    </SelectedValue>
    <SelectedValue>
      <Name>UPC</Name>
      <Value>Test11</Value>
    </SelectedValue>
    </SelectedValues>'
    )
    GO
    SELECT SV.S.value('(Value/text())[1]','varchar(10)') AS TextValue
    FROM #XML X
      CROSS APPLY X.XMLData.nodes('/SelectedValues/SelectedValue') SV (s)
    WHERE SV.S.value('(Name/text())[1]','varchar(10)') = 'UPC';
    GO
    DROP TABLE #XML;

    For Where, I'm only wanting to look at the values assigned to the UPC node.
    ('/SelectedValues/SelectedValue[Name="UPC" and Value[contains(.,"TEST10")] ]') = 1 ))