I have an XML file in a format similar to:
<XML>
<Field1>100</Field1>
<Field2>200</Field2>
<Field3>300</Field3>
<Test>400</Test>
</XML>
I need to write a query that will get all element values ββstarting with Field. Therefore, given XML, the result should be
FieldVal
--------
100
200
300
I tried the following, but it does not work:
Select
xc.value('text()', 'int')
From
@XMLData.nodes('/XML/[starts-with(name(), ''Field'')]') As xt(xc)
NOTE. . I am well aware that this task can be easily accomplished if I reformat my XML, but unfortunately I do not control the XML format.
source
share