I have this code in a SQL query:
CREATE TABLE Products(
P VARCHAR(30));
Select *
from products
Declare @x xml
Select @x=P
from openrowset (BULK 'C:\xmltest.xml', Single_blob) AS Products(P)
Select @x
Declare @hdoc int
Exec sp_xml_preparedocument @hdoc OUTPUT, @x
select *
From openxml (@hdoc, '/reservationDetailsResponse/reservation', 2)
with ( reservationNo int
)
Exec sp_xml_removedocument @hdoc
where i import an xml file called "xmltest", the xml file looks like this:
<reservationDetailsResponse xmlns="http://webservices.de/webservices/franchis/1.03" xmlns:xsi="http://www.w.org/20/XMLSchema-instance">
<reservation>
<reservationNo>9833591183</reservationNo>
<securityCode>ad4badfd52</securityCode>
<reference1 xsi:nil="true" />
<reference2 xsi:nil="true" />
<status>RS</status>
<revision xsi:nil="true" />
<language>es_ES</language>
<group>CFMR</group>
<duration>7</duration>
<voucherDays xsi:nil="true" />
<isLongterm>false</isLongterm>
<hasOwnInsurance>false</hasOwnInsurance>
<vipStatus xsi:nil="true" />
<customerRemark xsi:nil="true" />
<stationRemark>PREPAID, DRIVER MUST BE (System, 23.12.2015, 18:07:07)</stationRemark>
<flightNo>U2</flightNo>
<bonusProgramNo xsi:nil="true" />
<hasOnlinePaymentGuarantee>false</hasOnlinePaymentGuarantee>
</reservation>
</reservationDetailsResponse>
This code does work for another xml file that i have, but this one is different, the results always gives a empty table column(does not show the reservationNO values). There are also many reservations(repetition) in the xml file but i only pasted the first part. It is possible that the first line in the xml file reservationDetailsResponse is causing this, but i am not sure.