////////////////////////////////////////////////////
// xml1.prg
////////////////////////////////////////////////////
#include "/home/ivan/src/harbour/contrib/xhb/hbxml.ch"
function main()
local cFile:="./test.xml", cString
local cNote, cDiscount
local oDoc, oBook, oIterator, oCurrent
cString:=memoread( cFile )
if !( len(cString) > 0 )
wait "xml file unavailable"
return NIL
endif
oDoc:=TXmlDocument( 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 NIL
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide
<note>111</note>
</title>
<genre>Computer</genre>
<price>44.95
<discount>11</discount>
</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain
<note>222</note>
</title>
<genre>Fantasy</genre>
<price>5.95
<discount>12</discount>
</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant
<note>333</note>
</title>
<genre>Fantasy</genre>
<price>5.95
<discount>13</discount>
</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy
<note>444</note>
</title>
<genre>Fantasy</genre>
<price>5.95
<discount>14</discount>
</price>
<publish_date>2001-03-10</publish_date>
<description>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.</description>
</book>
<book id="bk105">
<author>Corets, Eva</author>
<title>The Sundered Grail
<note>555</note>
</title>
<genre>Fantasy</genre>
<price>5.95
<discount>15</discount>
</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters,
battle one another for control of England. Sequel to
Oberon's Legacy.</description>
</book>
</catalog>
On Wed, Apr 28, 2010 at 5:37 PM, Antonio Maniero <[email protected]> wrote:
> Please, post line 19 from your Main.
>
> []'s Maniero
>
>
> 2010/4/28 ivan re <[email protected]>
>
>>
>> $ hbmk2 xml1.prg -lxhb -L/usr/local/lib/harbour
>> hbmk2: Processing configuration: /usr/bin/hbmk.cfg
>> Harbour 2.1.0beta1 (Rev. 14394)
>> Copyright (c) 1999-2010, http://www.harbour-project.org/
>>
>>
>>
>> Compiling 'xml1.prg'...
>> Lines 168, Functions/Procedures 1
>> Generating C source output to '/tmp/xml1.c'... Done.
>>
>>
>> $ ./xml1
>>
>> Error BASE/1099 Argument error: STR
>>
>>
>>
>>
>> Called from STR(0)
>> Called from MAIN(19)
>>
>> Can someone help me?
>> TIA Ivan
>>
>>
>> _______________________________________________
>> Harbour mailing list (attachment size limit: 40KB)
>> [email protected]
>> http://lists.harbour-project.org/mailman/listinfo/harbour
>>
>>
>
> _______________________________________________
> Harbour mailing list (attachment size limit: 40KB)
> [email protected]
> http://lists.harbour-project.org/mailman/listinfo/harbour
>
>
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour