Update.....Can get it working with parameters for the elements:;with xmlnamespaces ('http://sysrepublic.com/Secure/4.0/DSL/ICMS/DynoFormData' as DFD)SELECT t.col.value('@value', 'nvarchar(200)')FROM @XML.nodes('/DFD:DynoFormData/DFD:*[local-name()=sql:variable("@path")]/DFD:*[local-name()=sql:variable("@elementName")]')AS t(col)
But not with the attribute defined as an element:;with xmlnamespaces ('http://sysrepublic.com/Secure/4.0/DSL/ICMS/DynoFormData' as DFD)SELECT t.col.value('@*[local-name()=sql:variable("@attributeName")]', 'nvarchar(200)')FROM @XML.nodes('/DFD:DynoFormData/DFD:*[local-name()=sql:variable("@path")]/DFD:*[local-name()=sql:variable("@elementName")]')AS t(col)
Error message:Msg 2389, Level 16, State 1, Line 52XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'