C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

C# Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

Non-recursive fast traversal of an XML document.

Non-recursive fast traversal of an XML document.

Download Chilkat .NET for 2.0 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

//  The Chilkat XML method ending in a "2" update the reference
//  within the XML object to the node that is fetched.
//  For example, xml.GetParent() returns a new XML object
//  that references the parent node, whereas xml.GetParent2()
//  updates the internal reference of the calling object,
//  and returns true or false (false if there is no parent).
//  The same goes for GetChild(index) vs. GetChild2(index).
//  The purpose of the "2" methods is to provide a means
//  for preventing the proliferation of objects that the
//  .NET garbage collection will need to clean up -- i.e.
//  it should make your programs run faster.

//  The "plants.xml" file can be downloaded from this URL:
//  http://www.chilkatsoft.com/testData/plants.xml

//  
Chilkat.Xml xml = new Chilkat.Xml();
            xml.LoadXmlFile("plants.xml");

            Stack<int> curIndex = new Stack<int>(100);
            Stack<int> numChildren = new Stack<int>(100);

            // We are on the 1st child for the current node...
            curIndex.Push(0);
            numChildren.Push(xml.NumChildren);

            bool finished = false;

            while (true)
            {
                int idx = curIndex.Peek();
                int nChildren = numChildren.Peek();

                // Have we finished with the children at this node?
                // If so, move back up to the parent.
                if (idx == nChildren)
                {
                    curIndex.Pop();
                    numChildren.Pop();
                    if (curIndex.Count == 0)
                    {
                        // We're done...
                        break;
                    }
                    xml.GetParent2();
                }
                else
                {
                    // Traverse to the Nth child.
                    xml.GetChild2(idx);

                    listBox1.Items.Add(xml.Tag + "(" + xml.Content + ")");

                    // Increment the current index at the top of the stack.
                    int tempIdx = curIndex.Pop();
                    curIndex.Push(tempIdx + 1);

                    // Does this child have any children?
                    int n = xml.NumChildren;
                    if (n > 0)
                    {
                        curIndex.Push(0);
                        numChildren.Push(n);
                    }
                    else
                    {
                        // Just move back up.
                        xml.GetParent2();
                    }
           
                }
                
            }

 

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

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

Email Component · XML Parser