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

THtmlIterator()

Creates a new THtmlIterator object.

Syntax

THtmlIterator():new( <oTHtmlNode> ) --> oTHtmlIterator

Arguments

<oTHtmlNode>
This is a THtmlNode() object to create the iterator object for.

Return

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

Description

The THtmlIterator class provides objects for iterating nodes in an HTML document and its sub-nodes. An HTML document is managed by an object of the THtmlDocument() class.

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

Methods

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

Info

See also:THtmlDocument(), THtmlNode(), THtmlIteratorScan(), THtmlIteratorRegEx()
Category: HTML functions , Object functions , xHarbour extensions
Source:tip\thtml.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example use the Google.html file as created with the
// THtmlDocument() example, extracts from it the <form>.
// tag and displays contained <input> variables.

   PROCEDURE Main
      LOCAL oHtmlDoc := THtmlDocument():new()
      LOCAL oHtmlNode, oHtmlIter

      oHtmlDoc:readFile( "Google.html" )

      oHtmlNode := oHtmlDoc:findFirst( "form" )
      oHtmlIter := THtmlIterator():new( oHtmlNode )

      DO WHILE .T.
         IF Lower( oHtmlNode:htmlTagName ) == "input"
            ? oHtmlNode:name , ;
              oHtmlNode:value, ;
              oHtmlNode:type
         ENDIF

         oHtmlNode := oHtmlIter:next()

         IF oHtmlNode == NIL
            EXIT
         ENDIF
      ENDDO
   RETURN

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