Beispiel #1
0
        public void TestTagName()
        {
            string html = @"<body><h1>title</h1>message</body>";
            HtmlDocument doc = new HtmlDocument(html);

            var q = new HtmlNavigator( doc )
                .Where( n => n.TagName == "h1" )
                .Select( n => n );
            Assert.AreEqual(1, q.Count());
            Assert.AreEqual("title", q.First().Value );
        }
Beispiel #2
0
        public void TestTagName()
        {
            string       html = @"<body><h1>title</h1>message</body>";
            HtmlDocument doc  = new HtmlDocument(html);

            var q = new HtmlNavigator(doc)
                    .Where(n => n.TagName == "h1")
                    .Select(n => n);

            Assert.AreEqual(1, q.Count());
            Assert.AreEqual("title", q.First().Value);
        }
Beispiel #3
0
        public void TestTagName2()
        {
            string html = @"<body><h2>title1</h2>message<h2>title2</h2></body>";
            HtmlDocument doc = new HtmlDocument(html);

            var q = new HtmlNavigator(doc)
                .Where(n => n.TagName == "h2")
                .Select(n => n);

            Assert.AreEqual(2, q.Count());
            Assert.AreEqual("title1", q.First().Value);
            Assert.AreEqual("title2", q.ToList()[1].Value);
        }
Beispiel #4
0
        public void TestTagName2()
        {
            string       html = @"<body><h2>title1</h2>message<h2>title2</h2></body>";
            HtmlDocument doc  = new HtmlDocument(html);

            var q = new HtmlNavigator(doc)
                    .Where(n => n.TagName == "h2")
                    .Select(n => n);

            Assert.AreEqual(2, q.Count());
            Assert.AreEqual("title1", q.First().Value);
            Assert.AreEqual("title2", q.ToList()[1].Value);
        }
Beispiel #5
0
        public void TestTagName4()
        {
            string       html = @"
<body>
    <h2>title1</h2>
        <span id='msg1'>message</span>
    <h2>title2</h2>
        <span id='msg2'>message2</span>
</body>
";
            HtmlDocument doc  = new HtmlDocument(html);

            var q = new HtmlNavigator(doc)
                    .Where(n => n % "id" == "msg2")
                    .Select(n => n);

            Assert.AreEqual(1, q.Count());
            Assert.AreEqual("message2", q.First().Value);
        }
Beispiel #6
0
        public void TestTagName4()
        {
            string html = @"
            <body>
            <h2>title1</h2>
            <span id='msg1'>message</span>
            <h2>title2</h2>
            <span id='msg2'>message2</span>
            </body>
            ";
            HtmlDocument doc = new HtmlDocument(html);

            var q = new HtmlNavigator(doc)
                .Where(n => n % "id" == "msg2")
                .Select(n => n);

            Assert.AreEqual(1, q.Count());
            Assert.AreEqual("message2", q.First().Value);
        }