SELECT dans un XML qui renvoie NULL
Bonjour à tous,
J'ai un champ au format XML avec la donnée suivante:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <SectionAnnotations xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SectionNumber>0</SectionNumber>
<Pages>
<PageAnnotations>
<PageNumber>0</PageNumber>
<Annotations>
<Layer xmlns="http://dev.test.com/schema/public/services/platform" Id="1">
<TextStamp Color="#008000" Transparent="true" Id="a3fe1750-fcce-4243-92d3-c7ad74557768" UserName="admin">
<Created User="admin" Time="2021-12-09T10:45:47Z" />
<Value>CONTRÔLEE</Value>
</TextStamp>
<TextStamp Color="#008000" Transparent="true" Id="b280e61c-d3b6-4525-8e39-038a47d8dcfe" UserName="admin">
<Created User="admin" Time="2021-12-09T10:47:56Z" />
<Value>A RENVOYER</Value>
</TextStamp>
</Layer>
</Annotations>
</PageAnnotations>
</Pages>
</SectionAnnotations> |
Avec la requête suivante (sous SQL Server), j'arrive à obtenir les valeurs de SectionNumber et PageNumber mais je n'arrive pas à extraire la valeur UserName :(
Cela me renvoie toujours une valeur null...
Code:
1 2 3 4 5
| select
xml.value('(/SectionAnnotations/Pages/PageAnnotations/PageNumber)[1]', 'varchar(max)') as pagenumber,
xml.value('(/SectionAnnotations/SectionNumber)[1]', 'varchar(max)') as sectionnumber,
xml.value('(/SectionAnnotations/Pages/PageAnnotations/Annotations/Layer/TextStamp/@UserName)[1]', 'varchar(max)') as 'User'
from matable |
Une idée?