Imaginando que temos o seguinte documento xml em uma base de dados, guardado no campo Strategy que é do tipo xml:
<strategy cacheDuration="01:00:00">
<pipeline type="RequestResponse">
<tasks>
<cache>
<duration>00:05:00</duration>
</cache>
...
</tasks>
</pipeline>
</strategy>
Se quisermos obter o valor do atributo cacheDuration e o texto do nó duration, fazemos a seguinte query:
SELECT strategy.value('data((/strategy)[1]/@cacheDuration)','varchar(50)') as StrategyCache,
strategy.value('data((/strategy/pipeline/tasks/cache/duration/text())[1])','varchar(50)') as TaskCache
FROM strategy
Resultado:
StrategyCache TaskCache
01:00:00 00:05:00
Sónia Moreira