Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2004, 10:25 AM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Milan
Default Urgent Help : XML to Sql temporary tables

my xml file is
<Date>05/11/2004
     <UserName> admin
         <FormName>frmErrorReport
             <Procedure>PrcEDIT
                     <ErrorNo>0</ErrorNo>
                     <ErrorDescription />aaaa
             </Procedure>
         </FormName>
     </UserName>
</Date>

i want to convert this in sql server as a temporary table
the sql i used is
************************************************** ******
DECLARE @xmlDoc VARCHAR(8000)
DECLARE @xmlHandle INT
BEGIN
    SET @xmlDoc =
'
     <Date>05/11/2004
     <UserName> admin
         <FormName>ErrorReport
             <Procedure>PrcEDIT
                     <ErrorNo>0</ErrorNo>
                     <ErrorDescription />aaaa
             </Procedure>
         </FormName>
     </UserName>
</Date>


'

    EXEC sp_xml_preparedocument @xmlHandle OUTPUT, @xmlDoc
    SELECT * FROM OPENXML (@xmlHandle, '/Date/UserName/FormName/procedure/errorNo/ErrorDescription',6) WITH
        (
            date1 varchar(20),
            UserName varchar(20),
            FormName varchar(20),
            Procedure1 varchar(20),
                        errorNo varchar(20),
                        ErrorDescription varchar(20)
)

    -- Important to specify this
    EXEC sp_xml_removedocument @xmlHandle
END

*****************************************

its returning only null values

anybody knows the answer plz help


Milan
 
Old November 6th, 2004, 06:16 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Your XPath does not match your document in terms of capitalisation, e.g.
Code:
 <Procedure> => /procedure
etc.


--

Joe (Co-author Beginning XML, 3rd edition)
 
Old November 6th, 2004, 07:36 AM
Authorized User
 
Join Date: Sep 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Milan
Default

<Date>05/11/2004
     <UserName> admin
          <FormName>frmErrorReport
               <Procedure>PrcEDIT
                     <ErrorNo>0</ErrorNo>
                     <ErrorDescription />aaaa
               </Procedure>
          </FormName>
     </UserName>
 </Date>
actually i need a file like above so can u tell me the correct xpath






Similar Threads
Thread Thread Starter Forum Replies Last Post
Temporary Tables Challenge! PCNHSL PHP How-To 1 November 8th, 2007 09:42 AM
creating temporary tables instead of queries clwk Access VBA 4 March 12th, 2007 02:50 PM
Crystal Report 8.0 - Working with Temporary Tables deebeedee VB How-To 0 July 27th, 2006 07:30 AM
Temporary tables eadred ADO.NET 4 August 8th, 2005 12:49 AM
Sql Server Temporary Tables itHighway SQL Server 2000 1 July 14th, 2005 12:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.