/// <summary>Parse a fragment of XML into a list of nodes.</summary> /// <param name="fragmentXml">the fragment of XML to parse</param> /// <param name="baseUri">base URI of document (i.e. original fetch location), for resolving relative URLs.</param> /// <returns>list of nodes parsed from the input XML.</returns> public static IList <iText.StyledXmlParser.Jsoup.Nodes.Node> ParseXmlFragment(String fragmentXml, String baseUri ) { XmlTreeBuilder treeBuilder = new XmlTreeBuilder(); return(treeBuilder.ParseFragment(fragmentXml, baseUri, ParseErrorList.NoTracking())); }
public virtual void TestCommentAndDocType() { String xml = "<!DOCTYPE html><!-- a comment -->One <qux />Two"; XmlTreeBuilder tb = new XmlTreeBuilder(); Document doc = tb.Parse(xml, "http://foo.com/"); NUnit.Framework.Assert.AreEqual("<!DOCTYPE html><!-- a comment -->One <qux />Two", TextUtil.StripNewlines( doc.Html())); }
public virtual 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/"); NUnit.Framework.Assert.AreEqual("<doc><val>One<val>Two</val>Three</val></doc>", TextUtil.StripNewlines(doc .Html())); }
public virtual 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/"); NUnit.Framework.Assert.AreEqual("<doc id=\"2\" href=\"/bar\">Foo <br /><link>One</link><link>Two</link></doc>" , TextUtil.StripNewlines(doc.Html())); NUnit.Framework.Assert.AreEqual(doc.GetElementById("2").AbsUrl("href"), "http://foo.com/bar"); }
/// <summary>Parse XML into a Document.</summary> /// <param name="xml">XML to parse</param> /// <param name="baseUri">base URI of document (i.e. original fetch location), for resolving relative URLs.</param> /// <returns>parsed Document</returns> public static Document ParseXml(String xml, String baseUri) { TreeBuilder treeBuilder = new XmlTreeBuilder(); return(treeBuilder.Parse(xml, baseUri, ParseErrorList.NoTracking())); }