Я пытаюсь проанализировать XML в T-SQL, но не понимаю, как написать свой код.
Мой вывод XML:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="https://api.quinyx.com/soap/FlexForce">
<SOAP-ENV:Body>
<ns1:wsdlGetTimePunchesResponse xmlns:ns1="uri:FlexForce">
<return xsi:type="tns:GetTimePunchesResponse">
<timepunches xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:TimePunch[1868]">
<item xsi:type="tns:TimePunch">
<id xsi:type="xsd:int">134054629</id>
<employeeName xsi:type="xsd:string">Test, Person</employeeName>
<restId xsi:type="xsd:int">1111</restId>
<badgeNo xsi:type="xsd:string">5000</badgeNo>
<socsecNo xsi:type="xsd:string" />
<cardNo xsi:type="xsd:string">5000</cardNo>
<punchIn xsi:type="xsd:dateTime">2019-01-14T08:00:00+01:00</punchIn>
<punchOut xsi:type="xsd:dateTime">2019-01-14T17:00:00+01:00</punchOut>
<hours xsi:type="xsd:decimal">8</hours>
<approvedByEmployee xsi:type="xsd:boolean">true</approvedByEmployee>
<approvedByManager xsi:type="xsd:boolean">true</approvedByManager>
<approvedByCustomer xsi:type="xsd:boolean">false</approvedByCustomer>
<costCentre xsi:type="xsd:string">8002</costCentre>
<projectNo xsi:type="xsd:string" />
<accountNo xsi:type="xsd:string" />
<agrmntAdditionalField1 xsi:type="xsd:string" />
<agrmntAdditionalField2 xsi:type="xsd:string" />
<agrmntAdditionalField3 xsi:type="xsd:string" />
<agrmntAdditionalField4 xsi:type="xsd:string" />
<agrmntAdditionalField5 xsi:type="xsd:string" />
<externalInfo1 xsi:type="xsd:string" />
<externalInfo2 xsi:type="xsd:string" />
<externalInfo3 xsi:type="xsd:string" />
<scheduleId xsi:type="xsd:int">2000000</scheduleId>
<transferredToPayroll xsi:type="xsd:boolean">true</transferredToPayroll>
<deleted xsi:type="xsd:boolean">false</deleted>
<productiveTime xsi:type="xsd:boolean">true</productiveTime>
<isOpen xsi:type="xsd:boolean">false</isOpen>
<comment xsi:type="xsd:string" />
<managerComment xsi:type="xsd:string" />
<employeeId xsi:type="xsd:int">1000000</employeeId>
<ts xsi:type="xsd:dateTime">2019-09-07T09:17:48+02:00</ts>
</item>
</timepunches>
<validationErrors xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[0]" />
</return>
XML сохраняется водин столбец в моей таблице базы данных.
Я пробовал несколько способов получить какие-либо данные, но все они ничего не показывают.
Даже не знает, с чего начать, если честно.
Это база данных SQL Server.
Вот существующий запрос:
select cast( replace(XMLData, '<?xml version="1.0" encoding="UTF-8"?>','') as xml) as XMLData into #temp from [Quniyx].[xmltest] select XMLData.value('return[1]/TimePunch[1]/item[1]/id[1]','int') from #temp