Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Fix_#41'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Kozák committed Aug 15, 2017
2 parents d012b60 + eaccd20 commit 0045144
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions source/std/experimental/xml/domparser.d
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ struct DOMBuilder(T, DOMImplementation = dom.DOMImplementation!(T.StringType))
{
switch (cursor.kind)
{
// XMLKind.elementEnd is needed for empty tags: <tag></tag>
case XMLKind.elementEnd:
case XMLKind.elementStart:
case XMLKind.elementEmpty:
auto elem = document.createElement(cursor.name);
Expand Down Expand Up @@ -260,4 +262,30 @@ unittest

assert(doc.getElementsByTagName("ccc").length == 1);
assert(doc.documentElement.getAttribute("xmlns:myns") == "something");
}

unittest
{
import std.experimental.xml.lexers;
import std.experimental.xml.parser;
import std.experimental.xml.cursor;
import std.experimental.allocator.gc_allocator;
import domimpl = std.experimental.xml.domimpl;

alias DOMImplType = domimpl.DOMImplementation!string;

auto xml = `<?xml version="1.0" encoding="UTF-8"?><tag></tag>`;
auto builder =
xml
.lexer
.parser
.cursor
.copyingCursor
.domBuilder(new DOMImplType());

builder.setSource(xml);
builder.buildRecursive;
auto doc = builder.getDocument;

assert(doc.childNodes.length == 1);
}

0 comments on commit 0045144

Please sign in to comment.