Friday, March 9, 2012

Help using sp_xml_preparedocument

Hi all,

We are using a VB component to create and save an XML document on our
local LAN.

We want to load this straight into a DB Table using a query based on
OPENXML. Trouble is, the sp_xml_preparedocument command always throws an
error.

Here is some code:

>>>> CODE >>>>
DECLARE @.idoc int
DECLARE @.doc varchar(1000)

EXEC sp_xml_preparedocument @.idoc OUTPUT, @.doc
<<<< END OF CODE <<<<

where @.doc is the filename of our file on the LAN to be opened, and
@.idoc is the handle to be created.

the error is:
XML parsing error: Invalid at the top level of the document.

Here is some of the XML Document saved on the LAN that should be opened
by sp_xml_preparedocument and prepared.

<?xml version="1.0" encoding="UTF-8" ?>
<xdata created_by="OSA" created_at="Thu Nov 13 11:33:33 EST 2003">
<rows row_count="1000">
<row>
<COL1>714761905</COL1>
<COL2>714761905</COL2>
<COL3>714761905</COL3>
</row>
</xdata
Any advice or tips whould be very helpful...

thanks

Phil

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!The xml doc you posted is not well-formed; it is mussing the </rows> end
tag. In any case, the @.doc parameter specifies the actual xml text, not
the path a file containing xml.

--
Hope this helps.

Dan Guzman
SQL Server MVP

--------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index...epartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--------

"no spam" <anonymous@.devdex.com> wrote in message
news:3fb4f782$0$198$75868355@.news.frii.net...
> Hi all,
> We are using a VB component to create and save an XML document on our
> local LAN.
> We want to load this straight into a DB Table using a query based on
> OPENXML. Trouble is, the sp_xml_preparedocument command always throws
an
> error.
> Here is some code:
> >>>> CODE >>>>
> DECLARE @.idoc int
> DECLARE @.doc varchar(1000)
> EXEC sp_xml_preparedocument @.idoc OUTPUT, @.doc
> <<<< END OF CODE <<<<
> where @.doc is the filename of our file on the LAN to be opened, and
> @.idoc is the handle to be created.
> the error is:
> XML parsing error: Invalid at the top level of the document.
> Here is some of the XML Document saved on the LAN that should be
opened
> by sp_xml_preparedocument and prepared.
> <?xml version="1.0" encoding="UTF-8" ?>
> <xdata created_by="OSA" created_at="Thu Nov 13 11:33:33 EST 2003">
> <rows row_count="1000">
> <row>
> <COL1>714761905</COL1>
> <COL2>714761905</COL2>
> <COL3>714761905</COL3>
> </row>
> </xdata>
> Any advice or tips whould be very helpful...
> thanks
> Phil
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

No comments:

Post a Comment