xHarbour Reference Documentation > Class Reference (textmode) xHarbour Developers Network  

TXmlIterator()

Creates a new TXmlIterator object.

Syntax

TXmlIterator():new( <oTXmlNode> ) --> oTXmlIterator

Arguments

<oTXmlNode>
This is a TXmlNode() object to create the iterator object for.

Return

The function returns a TXmlIterator object and method :new() initializes it.

Description

The TXmlIterator class provides objects for iterating nodes in an XML document and its sub-nodes (in the XML tree). An XML document is managed by an object of the TXmlDocument() class.

The creation of a TXmlIterator object requires a TXmlNode() object wich serves as starting point for the iterator. The iterator is restricted to the branch in the XML tree represented by the initial XML node.

Methods

:clone() --> oClone
Clones the TXmlIterator object.
:getNode() --> oTXmlNode | NIL
Retrieves the current XML node matching the search criteria.
:next() --> oTXmlNode | NIL
Retrieves the next XML node in the tree.
:rewind() --> oTXmlNode | NIL
Goes back to the first XML node matching the search criteria.
:setContext() --> self
Defines the currently found XML node as first node.

Info

See also:TXmlDocument(), TXmlNode(), TXmlIteratorScan(), TXmlIteratorRegEx()
Category: Object functions , xHarbour extensions
Source:rtl\txml.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example use the Customer.xml file as created with the
// TXmlDocument() example, and extracts from it the field names
// of the database structure. Note that the iterator is restricted
// to the subnodes of the "structure" node.

   PROCEDURE Main
      LOCAL oXmlDoc := TXmlDocument():new()
      LOCAL oXmlNode, oXmlIter

      oXMlDoc:read( Memoread( "customer.xml" ) )

      oXmlNode := oXmlDoc:findFirst( "structure" )

      oXmlIter := TXmlIterator():new( oXmlNode )

      DO WHILE .T.
         oXmlNode := oXmlIter:next()
         IF oXmlNode == NIL
            EXIT
         ENDIF

         ? oXmlNode:getAttribute( "name" )
      ENDDO
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe