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

TXmlIteratorScan()

Creates a new TXmlIteratorScan object.

Syntax

TXmlIteratorScan():new( <oTXmlNode> ) --> oTXmlIteratorScan

Arguments

<oTXmlNode>
This is a TXmlNode() object to create the iterator object for. It is the starting point for searching nodes in the XML tree.

Return

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

Description

The TXmlIteratorScan class is derived from the TXmlIterator() class and has the same methods. The only difference is that search criteria can be defined to find a particular XML node in an XML tree. The search criteria is defined once with the :find() method, which searches for the first matching XML node. Subsequent XML nodes matching the search criteria are then searched with the :next() method.

The end of a search is indicated when either :find() or :next() return NIL instead of a TXmlNode object matching the search criteria.

Search methods

:find( ... ) --> oTXmlNode | NIL
Searches the first XML node matching the search criteria.
:next() --> oTXmlNode | NIL
Searches the next XML node matching the search criteria.

Info

See also:TXmlDocument(), TXmlNode(), TXmlIterator(), 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. Two XmlIteratorScan objects are used
// to scan the <record> nodes and field nodes below record nodes.
// The example displays the reecord IDs and the data from the <lastname>
// nodes.

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

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

      oXmlNode := oXmlDoc:findFirst( "records" )

      // iterator for <record> nodes
      oXmlRecScan := TXmlIteratorScan():new( oXmlNode )
      oXmlNode    := oXmlRecScan:find( "record" )

      DO WHILE oXmlNode <> NIL
         ? oXmlNode:getAttribute( "id" )

         // iterator for <fieldname> nodes
         oXmlFieldScan := TXmlIteratorScan():new( oXmlNode )
         oXmlNode      := oXmlFieldScan:find( "lastname" )
         ?? " ", oXmlNode:cData

         oXmlNode := oXmlRecScan:next()
      ENDDO

   RETURN

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