From d385c7d55bd8d0926b0ce6e28b4f9466bad3fd7a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 28 Apr 2010 21:01:20 +0000 Subject: [PATCH] 2010-04-28 23:00 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + contrib/xhb/tests/xml1.prg + contrib/xhb/tests/test.xml + Added xml test code posted to list by "Ivan re". (after fix and formatting) ; TOFIX: This sample crashes with mingw. --- harbour/ChangeLog | 7 +++ harbour/contrib/xhb/tests/test.xml | 72 ++++++++++++++++++++++++++++++ harbour/contrib/xhb/tests/xml1.prg | 68 ++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 harbour/contrib/xhb/tests/test.xml create mode 100644 harbour/contrib/xhb/tests/xml1.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a836d5ec31..0c312eaa84 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,13 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-04-28 23:00 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + + contrib/xhb/tests/xml1.prg + + contrib/xhb/tests/test.xml + + Added xml test code posted to list by "Ivan re". + (after fix and formatting) + ; TOFIX: This sample crashes with mingw. + 2010-04-28 19:05 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/Makefile * src/rtl/getsys.prg diff --git a/harbour/contrib/xhb/tests/test.xml b/harbour/contrib/xhb/tests/test.xml new file mode 100644 index 0000000000..66ba19728e --- /dev/null +++ b/harbour/contrib/xhb/tests/test.xml @@ -0,0 +1,72 @@ + + + Gambardella, Matthew + XML Developer's Guide + <note>111</note> + + Computer + 44.95 + 11 + + 2000-10-01 + An in-depth look at creating applications + with XML. + + + Ralls, Kim + Midnight Rain + <note>222</note> + + Fantasy + 5.95 + 12 + + 2000-12-16 + A former architect battles corporate zombies, + an evil sorceress, and her own childhood to become queen + of the world. + + + Corets, Eva + Maeve Ascendant + <note>333</note> + + Fantasy + 5.95 + 13 + + 2000-11-17 + After the collapse of a nanotechnology + society in England, the young survivors lay the + foundation for a new society. + + + Corets, Eva + Oberon's Legacy + <note>444</note> + + Fantasy + 5.95 + 14 + + 2001-03-10 + In post-apocalypse England, the mysterious + agent known only as Oberon helps to create a new life + for the inhabitants of London. Sequel to Maeve + Ascendant. + + + Corets, Eva + The Sundered Grail + <note>555</note> + + Fantasy + 5.95 + 15 + + 2001-09-10 + The two daughters of Maeve, half-sisters, + battle one another for control of England. Sequel to + Oberon's Legacy. + + diff --git a/harbour/contrib/xhb/tests/xml1.prg b/harbour/contrib/xhb/tests/xml1.prg new file mode 100644 index 0000000000..ac7688c4b8 --- /dev/null +++ b/harbour/contrib/xhb/tests/xml1.prg @@ -0,0 +1,68 @@ +/* + * $Id$ + */ + +#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 NIL + ENDIF + + oDoc := TXmlDocument():New( cString, HBXML_STYLE_NOESCAPE ) + IF oDoc:nError != HBXML_ERROR_NONE + WAIT "xml file parsing error " + str(oDoc:nError) + RETURN NIL + ENDIF + + oBook := oDoc:findfirst( "book" ) + IF oBook == NIL + WAIT "no books found" + RETURN NIL + ENDIF + + DO WHILE .T. + + IF HHasKey( oBook:aAttributes, "id" ) + ? "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