added a helper method to get the child elements of an Element by name

This commit is contained in:
James Strachan
2012-10-09 09:12:34 +01:00
parent 6a59820de3
commit 8a9485bd5f
2 changed files with 16 additions and 2 deletions
@@ -117,6 +117,15 @@ class DomBuilderTest() {
} else {
fail("Not an Element $grandChild")
}
val child = doc["child"].first
if (child != null) {
val gc1 = child.childElements("grandChild")
assertEquals(1, gc1.size, "Expected a single child but found $gc1")
val gc2 = child.childElements("grandChild2")
assertEquals(1, gc2.size, "Expected a single child but found $gc2")
} else {
fail("No child found!")
}
val children = doc.documentElement.children()
val xml = nodesToXmlString(children)
println("root element has children: ${xml}")