Document.fragment

Create a document fragment from source

struct Document
fragment
(
const string html
)

Examples

version(DigitalMars) scope(exit) assert(Document.RefCounter.refs.length == 0);
version(DigitalMars) scope(exit) assert(Element.RefCounter.refs.length == 0);

Document doc = Document("<html>");
Element e = doc.fragment("<p><b>hello</b>world");

auto range = e.descendants();
assert(range.front.name == "p");
range.destroy();

import core.memory : GC;
GC.collect();

Meta