XMLTag
children with the tag_name
var code = """
<?xml version="1.0" encoding="us-ascii"?>
<animal>
<cat/>
<tiger>This is a white tiger!</tiger>
<cat/>
</animal>"""
var xml = code.to_xml
assert xml["animal"].length == 1
assert xml["animal"].first["cat"].length == 2
# The `XMLTag` children with the `tag_name`
#
# ~~~
# var code = """
# <?xml version="1.0" encoding="us-ascii"?>
# <animal>
# <cat/>
# <tiger>This is a white tiger!</tiger>
# <cat/>
# </animal>"""
#
# var xml = code.to_xml
# assert xml["animal"].length == 1
# assert xml["animal"].first["cat"].length == 2
# ~~~
fun [](tag_name: String): Array[XMLTag]
do
var res = new Array[XMLTag]
for child in children do
if child isa XMLTag and child.tag_name == tag_name then
res.add child
end
end
return res
end
lib/dom/dom.nit:18,2--42,4