Exemple #1
0
        public virtual void UnwrapNoChildren()
        {
            Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<div>One <span></span> Two</div>");

            iText.StyledXmlParser.Jsoup.Nodes.Element span = doc.Select("span").First();
            iText.StyledXmlParser.Jsoup.Nodes.Node    node = span.Unwrap();
            NUnit.Framework.Assert.AreEqual("<div>One  Two</div>", TextUtil.StripNewlines(doc.Body().Html()));
            NUnit.Framework.Assert.IsTrue(node == null);
        }
Exemple #2
0
        public virtual void Unwrap()
        {
            Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<div>One <span>Two <b>Three</b></span> Four</div>"
                                                                   );

            iText.StyledXmlParser.Jsoup.Nodes.Element span    = doc.Select("span").First();
            iText.StyledXmlParser.Jsoup.Nodes.Node    twoText = span.ChildNode(0);
            iText.StyledXmlParser.Jsoup.Nodes.Node    node    = span.Unwrap();
            NUnit.Framework.Assert.AreEqual("<div>One Two <b>Three</b> Four</div>", TextUtil.StripNewlines(doc.Body().
                                                                                                           Html()));
            NUnit.Framework.Assert.IsTrue(node is TextNode);
            NUnit.Framework.Assert.AreEqual("Two ", ((TextNode)node).Text());
            NUnit.Framework.Assert.AreEqual(node, twoText);
            NUnit.Framework.Assert.AreEqual(node.Parent(), doc.Select("div").First());
        }