Load an XML doc from a file

Tech-Archive recommends: Fix windows errors by optimizing your registry



I'm trying to do something similar to the code below, but I want to load the
XML document from a file on disk (ex.: c:\temp\mydoc.xml) instead of pasting
it into my code. Is there a way to do this in MSSQL 2005?

Thank you.

DECLARE @idoc int
declare @xmlDocument xml
set @xmlDocument = N'<?xml version="1.0"?>
<gpx version="1.1"
creator="GMapToGPX 4.14 - http://www.elsewhere.org/GMapToGPX/";
xmlns="http://www.topografix.com/GPX/1/1";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.topografix.com/GPX/1/1
http://www.topografix.com/GPX/1/1/gpx.xsd";>
<rte>
<name>Gmaps Pedometer Route</name>
<cmt>Permalink: <![CDATA[Permalink temporarily unavailable.]]>
</cmt>
<rtept lat="32.45358" lon="-110.97512">
<name>Start</name>
<ele>901.73556</ele>
</rtept>
<rtept lat="32.4537" lon="-110.97549">
<name>Turn 1</name>
<ele>902.01902</ele>
</rtept>
<rtept lat="32.45377" lon="-110.97594">
<name>Turn 2</name>
<ele>901.95196</ele>
</rtept>
<rtept lat="32.45376" lon="-110.97653">
<name>Turn 3</name>
<ele>902.22324</ele>
</rtept>
</rte>
</gpx>'
EXEC sp_xml_preparedocument @idoc OUTPUT, @xmlDocument, '<gpx
xmlns:gpxns="http://www.topografix.com/GPX/1/1"/>'
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT * FROM OPENXML (@idoc, '/gpxns:gpx/gpxns:rte/gpxns:rtept',3)
WITH (lat float, lon float, name varchar(60) 'gpxns:name', ele float
'gpxns:ele')

--


Alain Quesnel
alainsansspam@xxxxxxxxxxxx

www.logiquel.com


.



Relevant Pages

  • Re: nmnntp
    ... to use them is to open them in a text or hex editor and of the two, ... a long string buffer and write it to a file all at once; ... Think of an XML document ... "flatten" your data every time it goes to disk. ...
    (comp.lang.pascal.delphi.misc)
  • XmlDocument.Load failing with CR must be followed by LF
    ... Dim doc As New XmlDocument ... in VB.NET 2.0 to load an XML document for operating on the nodes thereof. ... System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId) ...
    (microsoft.public.dotnet.xml)
  • XmlDocument.Load failing with CR must be followed by LF
    ... Dim doc As New XmlDocument ... in VB.NET 2.0 to load an XML document for operating on the nodes thereof. ... System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId) ...
    (microsoft.public.dotnet.xml)
  • XmlDocument.Load throwing error saying CR must be followed by LF
    ... Dim doc As New XmlDocument ... in VB.NET 2.0 to load an XML document for operating on the nodes thereof. ... System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId) ...
    (microsoft.public.dotnet.xml)
  • Loading an XML Document?
    ... I am trying to load an XML document into memory in order to do stuff. ... Dim xmlDom As New Xml.XmlDocument ... I passed in a web URL and the very next line it is trying to open something from the local file system. ...
    (microsoft.public.dotnet.languages.vb)