arsd.dom appenChild method gives assertion message
Erdem via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Dec 11 10:30:53 PST 2016
Ok this seems to work as expected.
import arsd.dom;
import std.stdio;
void main()
{
auto document = new Document();
document.parseGarbage(`<html>
<head>
<title>Test Document1</title>
</head>
<body>
<p>This is the first paragraph of our <a
href="test.html">test document</a>.
<p>This second paragraph also has a <a
href="test2.html">link</a>.
<p id="custom-paragraph">Old text</p>
</body>
</html>`);
auto document2 = new Document();
document2.parseGarbage(`<html>
<head>
<title>Test Document</title>
</head>
<body>
<div id="foo"></div>
<a href="www.example.com"></a>
<div id="content">
</div>
<p id="custom-paragraph">Old text</p>
</body>
</html>`);
Element content =
document2.getElementsBySelector(`div[id="content"]`)[0];
writeln(content);
writeln();
Element[] firstElements =
document.getElementsBySelector("body")[0].children;
foreach (element; firstElements)
{
element.parentNode = null;
content.appendChild(element);
}
writeln(document2.toString());
}
More information about the Digitalmars-d-learn
mailing list