XML ATTRIBCOUNT() problem

new BookmarkLockedFalling
jstone71
New Member
*

jstone71 Avatar

Posts: 3Male

Post by jstone71 on Dec 14, 2016 15:25:03 GMT -5

Hi, I'm using the Linux version of Run Basic as a prototyping tool while I write functional requirements for a web app that will be coded in Python. I'm using the XML parser to process weather data sourced from the UK's Met Office. However, attribcount() appears to be returning results for the element that precedes it in the document tree. For example, the count for the REP element is given as 2, but this is the count for the parent PERIOD element not the REP element. Consequently, I can't access any of the REP element's 10 attribute/value pairs. Am I doing something wrong?

Code is as follows and I've attached a sample XML file.

open "test.xml" for input as #test
a = lof(#test)
doc1$ = input$(#test, a)
close #test

xmlparser #doc, doc1$
print #doc key$()
call displayElements #doc
end

sub displayElements #xmlDoc
count = #xmlDoc elementCount()
for x = 1 to count
#elem = #xmlDoc #element(x)
print "Key: "; #elem key$();
value$ = #elem value$()
attrib = #xmlDoc attribcount()
print " Value: "; value$; " | Attributes: "; attrib; " | Element count: "; count
for y = 1 to attrib
print #xmlDoc attribkey$(y);", "; #xmlDoc attribvalue$(y)
next y
print ""
call displayElements #elem
next x
end sub

Sample output:

Key: DV Value: | Attributes: 0 | Element count: 2 (actual number of attributes = 2)

Key: Location Value: | Attributes: 2 | Element count: 1 (actual number of attributes = 7)
dataDate, 2016年12月14日T16:00:00Z
type, Forecast

Key: Period Value: | Attributes: 7 | Element count: 5 (actual number of attributes = 2)
i, 354282
lat, 52.5938
lon, -2.1326
name, WOLVERHAMPTON WANDERERS F.C.
country, ENGLAND
continent, EUROPE
elevation, 128.0

Key: Rep Value: 720 | Attributes: 2 | Element count: 4 (actual number of attributes = 10)
type, Day
value, 2016年12月14日Z

Key: Rep Value: 900 | Attributes: 2 | Element count: 4
type, Day
value, 2016年12月14日Z

Key: Rep Value: 1080 | Attributes: 2 | Element count: 4
type, Day
value, 2016年12月14日Z

Key: Rep Value: 1260 | Attributes: 2 | Element count: 4
type, Day
value, 2016年12月14日Z

test.xml (3.78 KB)

Can anyone help?

Thanks.

jstone71
New Member
*

jstone71 Avatar

Posts: 3Male

meerkat
Senior Member
****

meerkat Avatar

Posts: 250

Post by meerkat on Jan 8, 2017 10:40:19 GMT -5

Is Run Basic dead or dying? Shame. It's really very useful.


I've ask the same question. Agreed that it's very useful.
If it's not dead, it's struggling to stay alive. I've had many bugs that need fixing. I even ask Carl in his webcase about a year ago if there were fixes. He indicated then that there would be fixes in about a week. Based on that discussion I continued to develop in RunBasic, only to have that hope dashed. This has happened several times, and I feel like Linus when Lucy yanks the football away.

I finally made the decision to move on. Unfortunate but had no choice. I looked all over and decided to go with REBOL.
REBOL is different and after a learning curve, I could write faster than in RunBasic. They are rewriting REBOL and it's called RED.

Sorry to see it go.

Good luck and hope something happens??
jstone71
New Member
*

jstone71 Avatar

Posts: 3Male

Post by jstone71 on Jan 11, 2017 7:39:48 GMT -5

meerkat Avatar
Is Run Basic dead or dying? Shame. It's really very useful.
I've ask the same question. Agreed that it's very useful.
If it's not dead, it's struggling to stay alive. I've had many bugs that need fixing. I even ask Carl in his webcase about a year ago if there were fixes. He indicated then that there would be fixes in about a week. Based on that discussion I continued to develop in RunBasic, only to have that hope dashed. This has happened several times, and I feel like Linus when Lucy yanks the football away.

I finally made the decision to move on. Unfortunate but had no choice. I looked all over and decided to go with REBOL.
REBOL is different and after a learning curve, I could write faster than in RunBasic. They are rewriting REBOL and it's called RED.

Sorry to see it go.

Good luck and hope something happens??

Thanks. Been looking for a multi-purpose alternative that isn't Python or Perl or Ruby. Just downloaded Red and it looks very interesting.