XML query filter by element name
While there's no messing with Mikael Eriksson when it comes to XML (he is, after all, my spiritual XML guide), here's an answer specific to your question.

You just have to change the way you're handling the XML a little bit. I also changed the XML a touch to rule out false positives searching for A and B in the node names to text 1 and text 2.

DECLARE @xmltable TABLE (xmlvalue XML)
INSERT @xmltable ( xmlvalue )
    VALUES ( '&lt;root&gt;&lt;A&gt;text 1&lt;/A&gt;&lt;B&gt;text 2&lt;/B&gt;&lt;/root&gt;' )

DECLARE @searchstring VARCHAR(100) = 'A'

SELECT x.*,
xa.c.value('.', 'VARCHAR(100)') AS [weird]
FROM @xmltable AS x
CROSS APPLY x.xmlvalue.nodes('/root/*[local-name()=sql:variable("@searchstring")]') xa (c)


This returns text 1.

DECLARE @xmltable TABLE (xmlvalue XML)
INSERT @xmltable ( xmlvalue )
    VALUES ( '&lt;root&gt;&lt;A&gt;text 1&lt;/A&gt;&lt;B&gt;text 2&lt;/B&gt;&lt;/root&gt;' )

    DECLARE @searchstring VARCHAR(100) = 'B'

    SELECT x.*,
    xa.c.value('.', 'VARCHAR(100)') AS [weird]
    FROM @xmltable AS x
    CROSS APPLY x.xmlvalue.nodes('/root/*[local-name()=sql:variable("@searchstring")]') xa (c)


This returns text 2.