示例#1
0
        public void checkAttributForTextComment()
        {
            var doc = new Candy.HtmlDocument();

            doc.LoadHtml(@"<html><body><div id='foo'><span> some</span> text</div></body></html>");
            var       div       = doc.GetElementbyId("foo");
            int       count     = 0;
            Exception exception = null;

            foreach (var textNode in div.ChildNodes)
            {
                try
                {
                    textNode.Id = "1";
                    count++;
                }
                catch (Exception e)
                {
                    exception = e;
                }
            }

            Assert.AreEqual(count, 1);
            Assert.IsNotNull(exception);
        }
示例#2
0
        /// <summary>
        /// Moves to the node that has an attribute of type ID whose value matches the specified string.
        /// </summary>
        /// <param name="id">A string representing the ID value of the node to which you want to move. This argument does not need to be atomized.</param>
        /// <returns>true if the move was successful, otherwise false. If false, the position of the navigator is unchanged.</returns>
        public override bool MoveToId(string id)
        {
#if TRACE_NAVIGATOR
            InternalTrace("id=" + id);
#endif
            HtmlNode node = _doc.GetElementbyId(id);
            if (node == null)
            {
#if TRACE_NAVIGATOR
                InternalTrace(">false");
#endif
                return(false);
            }

            _currentnode = node;
#if TRACE_NAVIGATOR
            InternalTrace(">true");
#endif
            return(true);
        }