xHarbour Reference Documentation > Class Reference (textmode) |
Creates a new TXmlIteratorRegEx object.
TXmlIteratorRegEx():new( <oTXmlNode> ) --> oTXmlIteratorRegEx
The function returns a TXmlIteratorRegEx object and method :new() initializes it.
The TXmlIteratorRegEx class is derived from the TXmlIterator() class and has the same methods. The only difference is that regular expressions are used to define search criteria for finding a particular XML node in an XML tree. The regular expressions are defined once with the :find() method, which searches for the first matching XML node. Subsequent XML nodes matching the regular expressions 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 regular expressions.
See also: | TXmlDocument(), TXmlNode(), TXmlIterator(), TXmlIteratorScan() |
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 contents of the <lastname> nodes // whose textual content begin with "R" or "S". PROCEDURE Main LOCAL oXmlDoc := TXmlDocument():new() LOCAL oXmlRecord, oXmlField, oXmlRecScan, oXmlFieldScan LOCAL cRegEx := "ˆ[R?]|ˆ[S?]" oXMlDoc:read( Memoread( "customer.xml" ) ) oXmlNode := oXmlDoc:findFirst( "records" ) // iterator for <record> nodes oXmlRecScan := TXmlIteratorScan():new( oXmlNode ) oXmlRecord := oXmlRecScan:find( "record" ) DO WHILE oXmlRecord <> NIL // iterator for <fieldname> nodes oXmlFieldScan := TXmlIteratorRegEx():new( oXmlRecord ) oXmlField := oXmlFieldScan:find( "lastname" ,,, cRegEx ) IF oXmlField <> NIL ? oXmlField:cData ENDIF oXmlRecord := oXmlRecScan:next() ENDDO RETURN
http://www.xHarbour.com