How about some XML?
DECLARE @idoc int
DECLARE @doc varchar(1000)
DECLARE @list varchar(100)
DECLARE @xpath varchar(50)
DECLARE @lookupID char(2)
SET @lookupID = '25'
SET @xpath = '/ROOT/Code[@codeID=' + @lookupID + ']/Alternate'
SET @list = ''
SET @doc ='
...