Add mitems and mpairs where it makes sense
This commit is contained in:
parent
6f4cd979e8
commit
46cf40c40d
5 changed files with 117 additions and 0 deletions
|
|
@ -115,11 +115,21 @@ proc `[]`* (n: XmlNode, i: int): XmlNode {.inline.} =
|
|||
assert n.k == xnElement
|
||||
result = n.s[i]
|
||||
|
||||
proc mget* (n: var XmlNode, i: int): var XmlNode {.inline.} =
|
||||
## returns the `i`'th child of `n` so that it can be modified
|
||||
assert n.k == xnElement
|
||||
result = n.s[i]
|
||||
|
||||
iterator items*(n: XmlNode): XmlNode {.inline.} =
|
||||
## iterates over any child of `n`.
|
||||
assert n.k == xnElement
|
||||
for i in 0 .. n.len-1: yield n[i]
|
||||
|
||||
iterator mitems*(n: var XmlNode): var XmlNode {.inline.} =
|
||||
## iterates over any child of `n`.
|
||||
assert n.k == xnElement
|
||||
for i in 0 .. n.len-1: yield mget(n, i)
|
||||
|
||||
proc attrs*(n: XmlNode): XmlAttributes {.inline.} =
|
||||
## gets the attributes belonging to `n`.
|
||||
## Returns `nil` if attributes have not been initialised for this node.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue