Exemple #1
0
 public void TestRemove2()
 {
     string html = @"
     <body>
     <h2>title1</h2>
     <span id='m1'>message</span>
     <h2>title2</h2>
     <span id='m2'>message2</span>
     </body>
     ";
     HtmlDocument doc = new HtmlDocument(html);
     var el = doc.Where(n => n.TagName == "span");
     doc.Remove( el );
     Assert.AreEqual(@"<body><h2>title1</h2><h2>title2</h2></body>", doc.Html );
 }
Exemple #2
0
        public void TestHtml2()
        {
            string html = @"<body><h1>title</h1>message</body>";
            HtmlDocument doc = new HtmlDocument(html);
            Assert.AreEqual(html, doc.Html);
            doc.Where(el => el.TagName == "h1").Update(el => el.Value = "TITLE");
            Assert.AreEqual(@"<body><h1>TITLE</h1>message</body>", doc.Html);

            doc.Where(el => el.Value == "message").Update(el => el.Value = "MESSAGE");
            Assert.AreEqual(@"<body><h1>TITLE</h1>MESSAGE</body>", doc.Html);
        }