import std.range.primitives : empty; import dxml.parser : TextPos; import dxml.util : stripIndent; auto xml = "<root>\n" ~ " <foo>\n" ~ " Foo and bar. Always foo and bar...\n" ~ " </foo>\n" ~ "</root>"; auto dom = parseDOM(xml); assert(dom.type == EntityType.elementStart); assert(dom.name.empty); assert(dom.pos == TextPos(1, 1)); auto root = dom.children[0]; assert(root.type == EntityType.elementStart); assert(root.name == "root"); assert(root.pos == TextPos(1, 1)); auto foo = root.children[0]; assert(foo.type == EntityType.elementStart); assert(foo.name == "foo"); assert(foo.pos == TextPos(2, 5)); auto text = foo.children[0]; assert(text.type == EntityType.text); assert(text.text.stripIndent() == "Foo and bar. Always foo and bar..."); assert(text.pos == TextPos(2, 10));
The position in the the original text where the entity starts.