DOMEntity.children

Returns the child entities of the current entity.

They are in the same order that they were in the XML document.

Supported EntityTypes:
elementStart
struct DOMEntity(R)
@property
children
()

Examples

1 auto xml = "<potato>\n" ~
2            "    <!--comment-->\n" ~
3            "    <foo>bar</foo>\n" ~
4            "    <tag>\n" ~
5            "        <silly>you</silly>\n" ~
6            "        <empty/>\n" ~
7            "        <nocontent></nocontent>\n" ~
8            "    </tag>\n" ~
9            "</potato>\n" ~
10            "<!--the end-->";
11 auto dom = parseDOM(xml);
12 assert(dom.children.length == 2);
13 
14 auto potato = dom.children[0];
15 assert(potato.type == EntityType.elementStart);
16 assert(potato.name == "potato");
17 assert(potato.children.length == 3);
18 
19 auto comment = potato.children[0];
20 assert(comment.type == EntityType.comment);
21 assert(comment.text == "comment");
22 
23 auto foo = potato.children[1];
24 assert(foo.type == EntityType.elementStart);
25 assert(foo.name == "foo");
26 assert(foo.children.length == 1);
27 
28 assert(foo.children[0].type == EntityType.text);
29 assert(foo.children[0].text == "bar");
30 
31 auto tag = potato.children[2];
32 assert(tag.type == EntityType.elementStart);
33 assert(tag.name == "tag");
34 assert(tag.children.length == 3);
35 
36 auto silly = tag.children[0];
37 assert(silly.type == EntityType.elementStart);
38 assert(silly.name == "silly");
39 assert(silly.children.length == 1);
40 
41 assert(silly.children[0].type == EntityType.text);
42 assert(silly.children[0].text == "you");
43 
44 auto empty = tag.children[1];
45 assert(empty.type == EntityType.elementEmpty);
46 assert(empty.name == "empty");
47 
48 auto nocontent = tag.children[2];
49 assert(nocontent.type == EntityType.elementStart);
50 assert(nocontent.name == "nocontent");
51 assert(nocontent.children.length == 0);
52 
53 auto endComment = dom.children[1];
54 assert(endComment.type == EntityType.comment);
55 assert(endComment.text == "the end");

Meta