diff options
author | Araq <rumpf_a@web.de> | 2011-04-01 15:07:16 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-04-01 15:07:16 +0200 |
commit | 4741e8f9a1d1148d58e129626952219e14ede255 (patch) | |
tree | db2eca2249ccc3230dc6c0a7359986198cab4048 /lib/pure/xmltree.nim | |
parent | dc669155e39007f1b584eef247dff90523f836bf (diff) | |
download | Nim-4741e8f9a1d1148d58e129626952219e14ede255.tar.gz |
ugh, maybe broke git
Diffstat (limited to 'lib/pure/xmltree.nim')
-rwxr-xr-x | lib/pure/xmltree.nim | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index 57988698b..41765b87a 100755 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -98,17 +98,17 @@ iterator items*(n: PXmlNode): PXmlNode {.inline.} = assert n.k == xnElement for i in 0 .. n.len-1: yield n[i] -proc attr*(n: PXmlNode): PXmlAttributes {.inline.} = +proc attrs*(n: PXmlNode): PXmlAttributes {.inline.} = ## gets the attributes belonging to `n`. assert n.k == xnElement result = n.fAttr -proc `attr=`*(n: PXmlNode, attr: PXmlAttributes) {.inline.} = +proc `attrs=`*(n: PXmlNode, attr: PXmlAttributes) {.inline.} = ## sets the attributes belonging to `n`. assert n.k == xnElement n.fAttr = attr -proc attrLen*(n: PXmlNode): int {.inline.} = +proc attrsLen*(n: PXmlNode): int {.inline.} = ## returns the number of `n`'s attributes. assert n.k == xnElement if not isNil(n.fAttr): result = len(n.fAttr) @@ -262,3 +262,16 @@ macro `<>`*(x: expr): expr = ## result = xmlConstructor(x) +proc child*(n: PXmlNode, name: string): PXmlNode = + ## Finds the first child element of `n` with a name of `name`. + ## Returns `nil` on failure. + assert n.kind == xnElement + for i in items(n): + if i.kind == xnElement: + if i.tag == name: + return i + +proc attr*(n: PXmlNode, name: string): string = + ## Finds the first attribute of `n` with a name of `name`. + assert n.kind == xnElement + return n.attrs[name] |