public void TestCommentAndDocType() { string xml = "<!DOCTYPE html><!-- a comment -->One <qux />Two"; XmlTreeBuilder tb = new XmlTreeBuilder(); Document doc = tb.Parse(xml, "http://foo.com/"); Assert.AreEqual("<!DOCTYPE html><!-- a comment -->One <qux />Two", TextUtil.StripNewlines(doc.Html)); }
public void TestPopToClose() { // test: </val> closes Two, </bar> ignored string xml = "<doc><val>One<val>Two</val></bar>Three</doc>"; XmlTreeBuilder tb = new XmlTreeBuilder(); Document doc = tb.Parse(xml, "http://foo.com/"); Assert.AreEqual("<doc><val>One<val>Two</val>Three</val></doc>", TextUtil.StripNewlines(doc.Html)); }
public void TestSimpleXmlParse() { string xml = "<doc id=2 href='/bar'>Foo <br /><link>One</link><link>Two</link></doc>"; XmlTreeBuilder tb = new XmlTreeBuilder(); Document doc = tb.Parse(xml, "http://foo.com/"); Assert.AreEqual("<doc id=\"2\" href=\"/bar\">Foo <br /><link>One</link><link>Two</link></doc>", TextUtil.StripNewlines(doc.Html)); Assert.AreEqual(doc.GetElementById("2").AbsUrl("href"), "http://foo.com/bar"); }