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

How to use GetParent and GetParent2

How to use GetParent and GetParent2. This is a snippet of the document used in this example:

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int

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

    DECLARE @xml int

    --  The Chilkat XML component is freeware.

    --  Load an XML document.  Typically you might call LoadXml
    --  to load an XML file.  This example loads an XML file from
    --  a URL:
    EXEC sp_OAMethod @xml0, 'HttpGet', @xml OUT, 'http://www.chilkatsoft.com/testData/bookstore.xml'

    --  The xml object points to the root node of the XML document.

    --  Set bookNode equal to the 1st child of the root.
    DECLARE @bookNode int

    EXEC sp_OAMethod @xml, 'GetChild', @bookNode OUT, 0

    --  Set titleNode equal to the title child of bookNode:
    DECLARE @titleNode int

    EXEC sp_OAMethod @bookNode, 'GetChildWithTag', @titleNode OUT, 'title'

    --  Call GetParent to return a new object pointing to the parent node:
    DECLARE @bookNode2 int

    EXEC sp_OAMethod @titleNode, 'GetParent', @bookNode2 OUT

    --  bookNode2 and bookNode point to the same node.

    --  Call GetParent2 (which returns nothing) to modify the internal
    --  pointer within the calling object so that it points to the immediate parent:
    EXEC sp_OAMethod @titleNode, 'GetParent2', NULL

    --  Now titleNode points to the same node as bookNode2 and bookNode.
    --  To prove it, generate the XML sub-tree rooted at the calling
    --  node and display each:
    DECLARE @str1 nvarchar(4000)

    DECLARE @str2 nvarchar(4000)

    DECLARE @str3 nvarchar(4000)

    EXEC sp_OAMethod @bookNode, 'GetXml', @str1 OUT
    EXEC sp_OAMethod @bookNode2, 'GetXml', @str2 OUT
    EXEC sp_OAMethod @titleNode, 'GetXml', @str3 OUT


    PRINT @str1

    PRINT @str2

    PRINT @str3

END
GO

 

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

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