* Makefile
* config/*
* contrib/*
* doc/*
* extras/*
* include/*
* lib/*
* package/*
* src/*
* tests/*
* utils/*
* removed empty lines left after removed '$' + 'Id' + '$' identifiers
68 lines
1.4 KiB
Plaintext
68 lines
1.4 KiB
Plaintext
#require "xhb"
|
|
|
|
#include "hbxml.ch"
|
|
|
|
PROCEDURE Main()
|
|
|
|
LOCAL cFile := hb_DirBase() + "test.xml"
|
|
LOCAL cString
|
|
LOCAL cNote, cDiscount
|
|
LOCAL oDoc, oBook, oIterator, oCurrent
|
|
|
|
cString := MemoRead( cFile )
|
|
|
|
IF Empty( cString )
|
|
WAIT "xml file unavailable"
|
|
RETURN
|
|
ENDIF
|
|
|
|
oDoc := TXMLDocument():New( cString, HBXML_STYLE_NOESCAPE )
|
|
IF oDoc:nError != HBXML_ERROR_NONE
|
|
WAIT "xml file parsing error " + hb_ntos( oDoc:nError )
|
|
RETURN
|
|
ENDIF
|
|
|
|
oBook := oDoc:findfirst( "book" )
|
|
IF oBook == NIL
|
|
WAIT "no books found"
|
|
RETURN
|
|
ENDIF
|
|
|
|
DO WHILE .T.
|
|
|
|
IF "id" $ oBook:aAttributes
|
|
? "book ID : " + oBook:aAttributes[ "id" ]
|
|
ELSE
|
|
? "no attribute book ID"
|
|
ENDIF
|
|
|
|
cNote := ""
|
|
cDiscount := ""
|
|
oIterator := TXMLIterator():New( oBook )
|
|
|
|
DO WHILE .T.
|
|
oCurrent := oIterator:Next()
|
|
IF oCurrent == NIL
|
|
? "end branch"
|
|
WAIT "values : " + cNote + " " + cDiscount
|
|
EXIT
|
|
ELSE
|
|
? "current tag : " + oCurrent:cName
|
|
IF oCurrent:cName == "note"
|
|
cNote := oCurrent:cData
|
|
ELSEIF oCurrent:cName == "discount"
|
|
cDiscount := oCurrent:cData
|
|
ENDIF
|
|
ENDIF
|
|
ENDDO
|
|
|
|
oBook := oDoc:findnext()
|
|
IF oBook == NIL
|
|
WAIT "no more books found"
|
|
EXIT
|
|
ENDIF
|
|
|
|
ENDDO
|
|
|
|
RETURN
|