SQL Server Stored Procedure Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
FTP
HTML-to-XML
HTTP
MHT
MIME
RSA Encryption
Socket
Spider
String
Tar
Upload
XML
XMP
Zip

Byte Array
RSS
Atom
Self-Extractor

Create XML Child Nodes with Attributes

How to create XML child nodes with attributes.

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int

    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  The Chilkat XML component is freeware.

    EXEC sp_OASetProperty @xml, 'Tag', 'product'

    DECLARE @xNode0 int

    EXEC sp_OAMethod @xml, 'NewChild', @xNode0 OUT, 'properties', ''

    DECLARE @xChild int

    EXEC sp_OAMethod @xNode0, 'NewChild', @xChild OUT, 'price', ''
    EXEC sp_OAMethod @xChild, 'AddAttribute', NULL, 'SellPrice', '11.99'

    EXEC sp_OAMethod @xNode0, 'NewChild', @xChild OUT, 'price', ''
    EXEC sp_OAMethod @xChild, 'AddAttribute', NULL, 'BasePrice', '11.99'

    EXEC sp_OAMethod @xml, 'GetXml', @iTmp0 OUT    PRINT @iTmp0

    --  Prints this:
    --  <product>
    --     <properties>
    --         <price SellPrice="11.99"></price>
    --         <price BasePrice="11.99"></price>
    --     </properties>
    -- </product>


END
GO

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.