SQL Server Stored Procedure Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
DKIM / DomainKey
FTP
HTML Conversion
HTTP
MHT
MIME
NTLM
RSA
Diffie-Hellman
DSA
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
String
Tar
Upload
XML
XMP
Zip

Amazon S3
Bz2
CSV
FileAccess
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

 

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