I have the following code to import an xml into SQL
DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)
SELECT @XML = XMLData FROM XMLwithOpenXML
EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML
SELECT rid, uid
FROM OPENXML(@hDoc, '/PportTimetable/Journey')
WITH
(
rid [varchar](50) '@rid',
uid [varchar](100) '@uid'
)
EXEC sp_xml_removedocument @hDoc
GO
I can get the code to work but only when it does not contain the xmlns information as seen below why is this?
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.thalesgroup.com/rtti/XmlTimetable/v8"
XML header
<PportTimetable xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" timetableID="20161018020822" xmlns="http://www.thalesgroup.com/rtti/XmlTimetable/v8">
<Journey rid="201610188012733" uid="P12733" trainId="2J27" ssd="2016-10-18" toc="AW">
</Journey>
</PportTimetable>