small xml functions
[1/1] from: bry::itnisk::com at: 24-Feb-2004 19:47
So I was working on doing a few little xml-
parse additions, enhancements, etc.
and I was starting on a documentElement
function:
documentElement: func[blockdom]
[currentNode: make
Object![tagname: pick blockdom 1
attributes: either block? pick blockdom 2
[length? pick blockdom 2][0]
]]
and it struck me that my idea of how I would
go after the attributes is undoubtedly wrong;
I was thinking that what I wanted was to do
stuff like
either currentNode/attributes > 0 [
;search for specific attribute and value
goes here
][;go next tag]
the question is how should the attributes be
organized, should they be as a single block
as they are now, should they be divided into
two words att-names: which holds the names
of the attributes, and att-values: which
hold the values of the attributes.
Of course there also has to be some pre-
sorting to remove namespace declarations
from attributes but that's not a biggie.
I think I would prefer to do
found? currentNode/att-names "class"
to skipping through a block, but then others
might not. Any ideas?