You can use something like this - Just showing the usage of variable part. Same thing you can do as part of modify call
Assuming you have hierarchy like this
<Root>
<Elem1/>
<Parent1/>
<Separator/>
<Child1/>
</Root>
Query:-
DECLARE @Root VARCHAR(50)
DECLARE @Entity VARCHAR(50)
DECLARE @ParentNode VARCHAR(50)
DECLARE @Separator VARCHAR(50)
DECLARE @ChildNode VARCHAR(50)
SET @Root = 'Root'
SET @Entity = 'Elem1'
SET @ParentNode = 'Parent1'
SET @Separator = 'separator'
SET @ChildNode = 'Child1'
select Parent.P.value('.', 'varchar(max)') as MyValue,
T.uniqueId, T.XMLCol
from [XMLTable] as T
cross apply XMLTable.XMLCol.nodes('(/*[local-name()=sql:variable("@Root")]/*[local-name(.)=sql:variable("@Entity")]/*[local-name(.)=sql:variable("@ParentNode")]/*[local-name(.)=sql:variable("@Separator")]/*[local-name(.)=sql:variable("@ChildNode")])[1]') as Parent(P)