xHarbour Reference Documentation > Class Reference (textmode) |
Creates a new TXmlIteratorScan object.
TXmlIteratorScan():new( <oTXmlNode> ) --> oTXmlIteratorScan
The function returns a TXmlIteratorScan object and method :new() initializes it.
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.
See also: | TXmlDocument(), TXmlNode(), TXmlIterator(), TXmlIteratorRegEx() |
Category: | Object functions , xHarbour extensions |
Source: | rtl\txml.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// 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
http://www.xHarbour.com