I am parsing XML and am receiving either one hash or list of more hashes, see:
qore -l xml -nX 'parse_xml("<root>
<row><id>1</id><name>foo</name></row>
<row><id>2</id><name>bar</name></row></root>")'
qore -l xml -nX 'parse_xml("<root>
<row><id>1</id><name>foo</name></row></root>")'
I need to know how many rows was parsed, but calling elements
or .size()
returns different values for list (amount of items) and hash (amount of keys!).
Is there a way ho to do it without the need to copy all values to new softlist variable?
hash xml = prase_xml("...");
softlist tmp = xml.root.row; # makes unnecessary copy!
tmp.size();
Thanks O.
use the <value>::lsize() pseudo-method, which returns:
1
for all other values0
for NOTHING
ex:
hash<auto> xml = parse_xml(xmlstr);
int size = xml.root.row.lsize();