public void test_replace_with_many_nominal() { DomDocument doc = new DomDocument(); var html = doc.AppendElement("html"); var body = html.AppendElement("body"); var h1 = body.AppendElement("h1"); var h3 = doc.CreateElement("h3"); var result = h1.ReplaceWith(h3, doc.CreateElement("h4"), doc.CreateElement("h5")); Assert.That(doc.ToXml(), Is.EqualTo("<html><body><h3 /><h4 /><h5 /></body></html>")); Assert.That(result, Is.SameAs(h3)); }
public void test_replace_with_document_element() { DomDocument doc = new DomDocument(); var html = doc.AppendText("leading ws"); var head = doc.CreateElement("head"); var result = html.ReplaceWith(head); Assert.That(doc.ToXml(), Is.EqualTo("<head />")); Assert.That(result, Is.SameAs(head)); }
public void test_to_xml_string() { DomDocument doc = new DomDocument(); // doc.AppendDocumentType("html"); var html = doc.AppendElement("html"); var body = html.AppendElement("body"); body.AppendElement("h1").AppendText("Hello, world"); html.Attribute("lang", "en"); // N.B. By default, xml decl is omitted Assert.That(doc.ToXml(), Is.EqualTo("<html lang=\"en\"><body><h1>Hello, world</h1></body></html>")); }