PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/mcs/class/System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/HtmlNodeNavigator.cs

https://github.com/acken/mono
C# | 806 lines | 537 code | 73 blank | 196 comment | 46 complexity | 6ba5b5a8386b7481653a802f9ccc8d6c MD5 | raw file
  1. // HtmlAgilityPack V1.0 - Simon Mourier <simonm@microsoft.com>
  2. using System;
  3. using System.Diagnostics;
  4. using System.Collections.Specialized;
  5. using System.IO;
  6. using System.Text;
  7. using System.Xml;
  8. using System.Xml.XPath;
  9. namespace HtmlAgilityPack
  10. {
  11. internal class HtmlNameTable: XmlNameTable
  12. {
  13. private NameTable _nametable = new NameTable();
  14. internal HtmlNameTable()
  15. {
  16. }
  17. internal string GetOrAdd(string array)
  18. {
  19. string s = Get(array);
  20. if (s == null)
  21. {
  22. return Add(array);
  23. }
  24. return s;
  25. }
  26. public override string Add(string array)
  27. {
  28. return _nametable.Add(array);
  29. }
  30. public override string Get(string array)
  31. {
  32. return _nametable.Get(array);
  33. }
  34. public override string Get(char[] array, int offset, int length)
  35. {
  36. return _nametable.Get(array, offset, length);
  37. }
  38. public override string Add(char[] array, int offset, int length)
  39. {
  40. return _nametable.Add(array, offset, length);
  41. }
  42. }
  43. /// <summary>
  44. /// Represents an HTML navigator on an HTML document seen as a data store.
  45. /// </summary>
  46. public class HtmlNodeNavigator: XPathNavigator
  47. {
  48. private HtmlDocument _doc = new HtmlDocument();
  49. private HtmlNode _currentnode;
  50. private int _attindex;
  51. private HtmlNameTable _nametable = new HtmlNameTable();
  52. internal bool Trace = false;
  53. internal HtmlNodeNavigator()
  54. {
  55. Reset();
  56. }
  57. private void Reset()
  58. {
  59. InternalTrace(null);
  60. _currentnode = _doc.DocumentNode;
  61. _attindex = -1;
  62. }
  63. [Conditional("TRACE")]
  64. internal void InternalTrace(object Value)
  65. {
  66. if (!Trace)
  67. {
  68. return;
  69. }
  70. string name = null;
  71. StackFrame sf = new StackFrame(1, true);
  72. name = sf.GetMethod().Name;
  73. string nodename;
  74. if (_currentnode == null)
  75. {
  76. nodename = "(null)";
  77. }
  78. else
  79. {
  80. nodename = _currentnode.Name;
  81. }
  82. string nodevalue;
  83. if (_currentnode == null)
  84. {
  85. nodevalue = "(null)";
  86. }
  87. else
  88. {
  89. switch(_currentnode.NodeType)
  90. {
  91. case HtmlNodeType.Comment:
  92. nodevalue = ((HtmlCommentNode)_currentnode).Comment;
  93. break;
  94. case HtmlNodeType.Document:
  95. nodevalue = "";
  96. break;
  97. case HtmlNodeType.Text:
  98. nodevalue = ((HtmlTextNode)_currentnode).Text;
  99. break;
  100. default:
  101. nodevalue = _currentnode.CloneNode(false).OuterHtml;
  102. break;
  103. }
  104. }
  105. System.Diagnostics.Trace.WriteLine("oid=" + GetHashCode()
  106. + ",n=" + nodename
  107. + ",a=" + _attindex + ","
  108. + ",v=" + nodevalue + ","
  109. + Value, "N!"+ name);
  110. }
  111. internal HtmlNodeNavigator(HtmlDocument doc, HtmlNode currentNode)
  112. {
  113. if (currentNode == null)
  114. {
  115. throw new ArgumentNullException("currentNode");
  116. }
  117. if (currentNode.OwnerDocument != doc)
  118. {
  119. throw new ArgumentException(HtmlDocument.HtmlExceptionRefNotChild);
  120. }
  121. InternalTrace(null);
  122. _doc = doc;
  123. Reset();
  124. _currentnode = currentNode;
  125. }
  126. private HtmlNodeNavigator(HtmlNodeNavigator nav)
  127. {
  128. if (nav == null)
  129. {
  130. throw new ArgumentNullException("nav");
  131. }
  132. InternalTrace(null);
  133. _doc = nav._doc;
  134. _currentnode = nav._currentnode;
  135. _attindex = nav._attindex;
  136. _nametable = nav._nametable; // REVIEW: should we do this?
  137. }
  138. /// <summary>
  139. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.
  140. /// </summary>
  141. /// <param name="stream">The input stream.</param>
  142. public HtmlNodeNavigator(Stream stream)
  143. {
  144. _doc.Load(stream);
  145. Reset();
  146. }
  147. /// <summary>
  148. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.
  149. /// </summary>
  150. /// <param name="stream">The input stream.</param>
  151. /// <param name="detectEncodingFromByteOrderMarks">Indicates whether to look for byte order marks at the beginning of the stream.</param>
  152. public HtmlNodeNavigator(Stream stream, bool detectEncodingFromByteOrderMarks)
  153. {
  154. _doc.Load(stream, detectEncodingFromByteOrderMarks);
  155. Reset();
  156. }
  157. /// <summary>
  158. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.
  159. /// </summary>
  160. /// <param name="stream">The input stream.</param>
  161. /// <param name="encoding">The character encoding to use.</param>
  162. public HtmlNodeNavigator(Stream stream, Encoding encoding)
  163. {
  164. _doc.Load(stream, encoding);
  165. Reset();
  166. }
  167. /// <summary>
  168. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.
  169. /// </summary>
  170. /// <param name="stream">The input stream.</param>
  171. /// <param name="encoding">The character encoding to use.</param>
  172. /// <param name="detectEncodingFromByteOrderMarks">Indicates whether to look for byte order marks at the beginning of the stream.</param>
  173. public HtmlNodeNavigator(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks)
  174. {
  175. _doc.Load(stream, encoding, detectEncodingFromByteOrderMarks);
  176. Reset();
  177. }
  178. /// <summary>
  179. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.
  180. /// </summary>
  181. /// <param name="stream">The input stream.</param>
  182. /// <param name="encoding">The character encoding to use.</param>
  183. /// <param name="detectEncodingFromByteOrderMarks">Indicates whether to look for byte order marks at the beginning of the stream.</param>
  184. /// <param name="buffersize">The minimum buffer size.</param>
  185. public HtmlNodeNavigator(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int buffersize)
  186. {
  187. _doc.Load(stream, encoding, detectEncodingFromByteOrderMarks, buffersize);
  188. Reset();
  189. }
  190. /// <summary>
  191. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a TextReader.
  192. /// </summary>
  193. /// <param name="reader">The TextReader used to feed the HTML data into the document.</param>
  194. public HtmlNodeNavigator(TextReader reader)
  195. {
  196. _doc.Load(reader);
  197. Reset();
  198. }
  199. /// <summary>
  200. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.
  201. /// </summary>
  202. /// <param name="path">The complete file path to be read.</param>
  203. public HtmlNodeNavigator(string path)
  204. {
  205. _doc.Load(path);
  206. Reset();
  207. }
  208. /// <summary>
  209. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.
  210. /// </summary>
  211. /// <param name="path">The complete file path to be read.</param>
  212. /// <param name="detectEncodingFromByteOrderMarks">Indicates whether to look for byte order marks at the beginning of the file.</param>
  213. public HtmlNodeNavigator(string path, bool detectEncodingFromByteOrderMarks)
  214. {
  215. _doc.Load(path, detectEncodingFromByteOrderMarks);
  216. Reset();
  217. }
  218. /// <summary>
  219. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.
  220. /// </summary>
  221. /// <param name="path">The complete file path to be read.</param>
  222. /// <param name="encoding">The character encoding to use.</param>
  223. public HtmlNodeNavigator(string path, Encoding encoding)
  224. {
  225. _doc.Load(path, encoding);
  226. Reset();
  227. }
  228. /// <summary>
  229. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.
  230. /// </summary>
  231. /// <param name="path">The complete file path to be read.</param>
  232. /// <param name="encoding">The character encoding to use.</param>
  233. /// <param name="detectEncodingFromByteOrderMarks">Indicates whether to look for byte order marks at the beginning of the file.</param>
  234. public HtmlNodeNavigator(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks)
  235. {
  236. _doc.Load(path, encoding, detectEncodingFromByteOrderMarks);
  237. Reset();
  238. }
  239. /// <summary>
  240. /// Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.
  241. /// </summary>
  242. /// <param name="path">The complete file path to be read.</param>
  243. /// <param name="encoding">The character encoding to use.</param>
  244. /// <param name="detectEncodingFromByteOrderMarks">Indicates whether to look for byte order marks at the beginning of the file.</param>
  245. /// <param name="buffersize">The minimum buffer size.</param>
  246. public HtmlNodeNavigator(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int buffersize)
  247. {
  248. _doc.Load(path, encoding, detectEncodingFromByteOrderMarks, buffersize);
  249. Reset();
  250. }
  251. /// <summary>
  252. /// Gets the name of the current HTML node without the namespace prefix.
  253. /// </summary>
  254. public override string LocalName
  255. {
  256. get
  257. {
  258. if (_attindex != -1)
  259. {
  260. InternalTrace("att>" + _currentnode.Attributes[_attindex].Name);
  261. return _nametable.GetOrAdd(_currentnode.Attributes[_attindex].Name);
  262. }
  263. else
  264. {
  265. InternalTrace("node>" + _currentnode.Name);
  266. return _nametable.GetOrAdd(_currentnode.Name);
  267. }
  268. }
  269. }
  270. /// <summary>
  271. /// Gets the namespace URI (as defined in the W3C Namespace Specification) of the current node.
  272. /// Always returns string.Empty in the case of HtmlNavigator implementation.
  273. /// </summary>
  274. public override string NamespaceURI
  275. {
  276. get
  277. {
  278. InternalTrace(">");
  279. return _nametable.GetOrAdd(string.Empty);
  280. }
  281. }
  282. /// <summary>
  283. /// Gets the qualified name of the current node.
  284. /// </summary>
  285. public override string Name
  286. {
  287. get
  288. {
  289. InternalTrace(">" + _currentnode.Name);
  290. return _nametable.GetOrAdd(_currentnode.Name);
  291. }
  292. }
  293. /// <summary>
  294. /// Gets the prefix associated with the current node.
  295. /// Always returns string.Empty in the case of HtmlNavigator implementation.
  296. /// </summary>
  297. public override string Prefix
  298. {
  299. get
  300. {
  301. InternalTrace(null);
  302. return _nametable.GetOrAdd(string.Empty);
  303. }
  304. }
  305. /// <summary>
  306. /// Gets the type of the current node.
  307. /// </summary>
  308. public override XPathNodeType NodeType
  309. {
  310. get
  311. {
  312. switch(_currentnode.NodeType)
  313. {
  314. case HtmlNodeType.Comment:
  315. InternalTrace(">" + XPathNodeType.Comment);
  316. return XPathNodeType.Comment;
  317. case HtmlNodeType.Document:
  318. InternalTrace(">" + XPathNodeType.Root);
  319. return XPathNodeType.Root;
  320. case HtmlNodeType.Text:
  321. InternalTrace(">" + XPathNodeType.Text);
  322. return XPathNodeType.Text;
  323. case HtmlNodeType.Element:
  324. {
  325. if (_attindex != -1)
  326. {
  327. InternalTrace(">" + XPathNodeType.Attribute);
  328. return XPathNodeType.Attribute;
  329. }
  330. InternalTrace(">" + XPathNodeType.Element);
  331. return XPathNodeType.Element;
  332. }
  333. default:
  334. throw new NotImplementedException("Internal error: Unhandled HtmlNodeType: " + _currentnode.NodeType);
  335. }
  336. }
  337. }
  338. /// <summary>
  339. /// Gets the text value of the current node.
  340. /// </summary>
  341. public override string Value
  342. {
  343. get
  344. {
  345. InternalTrace("nt=" + _currentnode.NodeType);
  346. switch(_currentnode.NodeType)
  347. {
  348. case HtmlNodeType.Comment:
  349. InternalTrace(">" + ((HtmlCommentNode)_currentnode).Comment);
  350. return ((HtmlCommentNode)_currentnode).Comment;
  351. case HtmlNodeType.Document:
  352. InternalTrace(">");
  353. return "";
  354. case HtmlNodeType.Text:
  355. InternalTrace(">" + ((HtmlTextNode)_currentnode).Text);
  356. return ((HtmlTextNode)_currentnode).Text;
  357. case HtmlNodeType.Element:
  358. {
  359. if (_attindex != -1)
  360. {
  361. InternalTrace(">" + _currentnode.Attributes[_attindex].Value);
  362. return _currentnode.Attributes[_attindex].Value;
  363. }
  364. return _currentnode.InnerText;
  365. }
  366. default:
  367. throw new NotImplementedException("Internal error: Unhandled HtmlNodeType: " + _currentnode.NodeType);
  368. }
  369. }
  370. }
  371. /// <summary>
  372. /// Gets the base URI for the current node.
  373. /// Always returns string.Empty in the case of HtmlNavigator implementation.
  374. /// </summary>
  375. public override string BaseURI
  376. {
  377. get
  378. {
  379. InternalTrace(">");
  380. return _nametable.GetOrAdd(string.Empty);
  381. }
  382. }
  383. /// <summary>
  384. /// Gets the xml:lang scope for the current node.
  385. /// Always returns string.Empty in the case of HtmlNavigator implementation.
  386. /// </summary>
  387. public override string XmlLang
  388. {
  389. get
  390. {
  391. InternalTrace(null);
  392. return _nametable.GetOrAdd(string.Empty);
  393. }
  394. }
  395. /// <summary>
  396. /// Gets a value indicating whether the current node is an empty element.
  397. /// </summary>
  398. public override bool IsEmptyElement
  399. {
  400. get
  401. {
  402. InternalTrace(">" + !HasChildren);
  403. // REVIEW: is this ok?
  404. return !HasChildren;
  405. }
  406. }
  407. /// <summary>
  408. /// Gets the XmlNameTable associated with this implementation.
  409. /// </summary>
  410. public override XmlNameTable NameTable
  411. {
  412. get
  413. {
  414. InternalTrace(null);
  415. return _nametable;
  416. }
  417. }
  418. /// <summary>
  419. /// Gets a value indicating whether the current node has child nodes.
  420. /// </summary>
  421. public override bool HasAttributes
  422. {
  423. get
  424. {
  425. InternalTrace(">" + (_currentnode.Attributes.Count>0));
  426. return (_currentnode.Attributes.Count>0);
  427. }
  428. }
  429. /// <summary>
  430. /// Gets a value indicating whether the current node has child nodes.
  431. /// </summary>
  432. public override bool HasChildren
  433. {
  434. get
  435. {
  436. InternalTrace(">" + (_currentnode.ChildNodes.Count>0));
  437. return (_currentnode.ChildNodes.Count>0);
  438. }
  439. }
  440. /// <summary>
  441. /// Moves to the next sibling of the current node.
  442. /// </summary>
  443. /// <returns>true if the navigator is successful moving to the next sibling node, false if there are no more siblings or if the navigator is currently positioned on an attribute node. If false, the position of the navigator is unchanged.</returns>
  444. public override bool MoveToNext()
  445. {
  446. if (_currentnode.NextSibling == null)
  447. {
  448. InternalTrace(">false");
  449. return false;
  450. }
  451. InternalTrace("_c=" + _currentnode.CloneNode(false).OuterHtml);
  452. InternalTrace("_n=" + _currentnode.NextSibling.CloneNode(false).OuterHtml);
  453. _currentnode = _currentnode.NextSibling;
  454. InternalTrace(">true");
  455. return true;
  456. }
  457. /// <summary>
  458. /// Moves to the previous sibling of the current node.
  459. /// </summary>
  460. /// <returns>true if the navigator is successful moving to the previous sibling node, false if there is no previous sibling or if the navigator is currently positioned on an attribute node.</returns>
  461. public override bool MoveToPrevious()
  462. {
  463. if (_currentnode.PreviousSibling == null)
  464. {
  465. InternalTrace(">false");
  466. return false;
  467. }
  468. _currentnode = _currentnode.PreviousSibling;
  469. InternalTrace(">true");
  470. return true;
  471. }
  472. /// <summary>
  473. /// Moves to the first sibling of the current node.
  474. /// </summary>
  475. /// <returns>true if the navigator is successful moving to the first sibling node, false if there is no first sibling or if the navigator is currently positioned on an attribute node.</returns>
  476. public override bool MoveToFirst()
  477. {
  478. if (_currentnode.ParentNode == null)
  479. {
  480. InternalTrace(">false");
  481. return false;
  482. }
  483. if (_currentnode.ParentNode.FirstChild == null)
  484. {
  485. InternalTrace(">false");
  486. return false;
  487. }
  488. _currentnode = _currentnode.ParentNode.FirstChild;
  489. InternalTrace(">true");
  490. return true;
  491. }
  492. /// <summary>
  493. /// Moves to the first child of the current node.
  494. /// </summary>
  495. /// <returns>true if there is a first child node, otherwise false.</returns>
  496. public override bool MoveToFirstChild()
  497. {
  498. if (!_currentnode.HasChildNodes)
  499. {
  500. InternalTrace(">false");
  501. return false;
  502. }
  503. _currentnode = _currentnode.ChildNodes[0];
  504. InternalTrace(">true");
  505. return true;
  506. }
  507. /// <summary>
  508. /// Moves to the parent of the current node.
  509. /// </summary>
  510. /// <returns>true if there is a parent node, otherwise false.</returns>
  511. public override bool MoveToParent()
  512. {
  513. if (_currentnode.ParentNode == null)
  514. {
  515. InternalTrace(">false");
  516. return false;
  517. }
  518. _currentnode = _currentnode.ParentNode;
  519. InternalTrace(">true");
  520. return true;
  521. }
  522. /// <summary>
  523. /// Moves to the root node to which the current node belongs.
  524. /// </summary>
  525. public override void MoveToRoot()
  526. {
  527. _currentnode = _doc.DocumentNode;
  528. InternalTrace(null);
  529. }
  530. /// <summary>
  531. /// Moves to the same position as the specified HtmlNavigator.
  532. /// </summary>
  533. /// <param name="other">The HtmlNavigator positioned on the node that you want to move to.</param>
  534. /// <returns>true if successful, otherwise false. If false, the position of the navigator is unchanged.</returns>
  535. public override bool MoveTo(XPathNavigator other)
  536. {
  537. HtmlNodeNavigator nav = other as HtmlNodeNavigator;
  538. if (nav == null)
  539. {
  540. InternalTrace(">false (nav is not an HtmlNodeNavigator)");
  541. return false;
  542. }
  543. InternalTrace("moveto oid=" + nav.GetHashCode()
  544. + ", n:" + nav._currentnode.Name
  545. + ", a:" + nav._attindex);
  546. if (nav._doc == _doc)
  547. {
  548. _currentnode = nav._currentnode;
  549. _attindex = nav._attindex;
  550. InternalTrace(">true");
  551. return true;
  552. }
  553. // we don't know how to handle that
  554. InternalTrace(">false (???)");
  555. return false;
  556. }
  557. /// <summary>
  558. /// Moves to the node that has an attribute of type ID whose value matches the specified string.
  559. /// </summary>
  560. /// <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>
  561. /// <returns>true if the move was successful, otherwise false. If false, the position of the navigator is unchanged.</returns>
  562. public override bool MoveToId(string id)
  563. {
  564. InternalTrace("id=" + id);
  565. HtmlNode node = _doc.GetElementbyId(id);
  566. if (node == null)
  567. {
  568. InternalTrace(">false");
  569. return false;
  570. }
  571. _currentnode = node;
  572. InternalTrace(">true");
  573. return true;
  574. }
  575. /// <summary>
  576. /// Determines whether the current HtmlNavigator is at the same position as the specified HtmlNavigator.
  577. /// </summary>
  578. /// <param name="other">The HtmlNavigator that you want to compare against.</param>
  579. /// <returns>true if the two navigators have the same position, otherwise, false.</returns>
  580. public override bool IsSamePosition(XPathNavigator other)
  581. {
  582. HtmlNodeNavigator nav = other as HtmlNodeNavigator;
  583. if (nav == null)
  584. {
  585. InternalTrace(">false");
  586. return false;
  587. }
  588. InternalTrace(">" + (nav._currentnode == _currentnode));
  589. return (nav._currentnode == _currentnode);
  590. }
  591. /// <summary>
  592. /// Creates a new HtmlNavigator positioned at the same node as this HtmlNavigator.
  593. /// </summary>
  594. /// <returns>A new HtmlNavigator object positioned at the same node as the original HtmlNavigator.</returns>
  595. public override XPathNavigator Clone()
  596. {
  597. InternalTrace(null);
  598. return new HtmlNodeNavigator(this);
  599. }
  600. /// <summary>
  601. /// Gets the value of the HTML attribute with the specified LocalName and NamespaceURI.
  602. /// </summary>
  603. /// <param name="localName">The local name of the HTML attribute.</param>
  604. /// <param name="namespaceURI">The namespace URI of the attribute. Unsupported with the HtmlNavigator implementation.</param>
  605. /// <returns>The value of the specified HTML attribute. String.Empty or null if a matching attribute is not found or if the navigator is not positioned on an element node.</returns>
  606. public override string GetAttribute(string localName, string namespaceURI)
  607. {
  608. InternalTrace("localName=" + localName + ", namespaceURI=" + namespaceURI);
  609. HtmlAttribute att = _currentnode.Attributes[localName];
  610. if (att == null)
  611. {
  612. InternalTrace(">null");
  613. return null;
  614. }
  615. InternalTrace(">" + att.Value);
  616. return att.Value;
  617. }
  618. /// <summary>
  619. /// Moves to the HTML attribute with matching LocalName and NamespaceURI.
  620. /// </summary>
  621. /// <param name="localName">The local name of the HTML attribute.</param>
  622. /// <param name="namespaceURI">The namespace URI of the attribute. Unsupported with the HtmlNavigator implementation.</param>
  623. /// <returns>true if the HTML attribute is found, otherwise, false. If false, the position of the navigator does not change.</returns>
  624. public override bool MoveToAttribute(string localName, string namespaceURI)
  625. {
  626. InternalTrace("localName=" + localName + ", namespaceURI=" + namespaceURI);
  627. int index = _currentnode.Attributes.GetAttributeIndex(localName);
  628. if (index == -1)
  629. {
  630. InternalTrace(">false");
  631. return false;
  632. }
  633. _attindex = index;
  634. InternalTrace(">true");
  635. return true;
  636. }
  637. /// <summary>
  638. /// Moves to the first HTML attribute.
  639. /// </summary>
  640. /// <returns>true if the navigator is successful moving to the first HTML attribute, otherwise, false.</returns>
  641. public override bool MoveToFirstAttribute()
  642. {
  643. if (!HasAttributes)
  644. {
  645. InternalTrace(">false");
  646. return false;
  647. }
  648. _attindex = 0;
  649. InternalTrace(">true");
  650. return true;
  651. }
  652. /// <summary>
  653. /// Moves to the next HTML attribute.
  654. /// </summary>
  655. /// <returns></returns>
  656. public override bool MoveToNextAttribute()
  657. {
  658. InternalTrace(null);
  659. if (_attindex>=(_currentnode.Attributes.Count-1))
  660. {
  661. InternalTrace(">false");
  662. return false;
  663. }
  664. _attindex++;
  665. InternalTrace(">true");
  666. return true;
  667. }
  668. /// <summary>
  669. /// Returns the value of the namespace node corresponding to the specified local name.
  670. /// Always returns string.Empty for the HtmlNavigator implementation.
  671. /// </summary>
  672. /// <param name="name">The local name of the namespace node.</param>
  673. /// <returns>Always returns string.Empty for the HtmlNavigator implementation.</returns>
  674. public override string GetNamespace(string name)
  675. {
  676. InternalTrace("name=" + name);
  677. return string.Empty;
  678. }
  679. /// <summary>
  680. /// Moves the XPathNavigator to the namespace node with the specified local name.
  681. /// Always returns false for the HtmlNavigator implementation.
  682. /// </summary>
  683. /// <param name="name">The local name of the namespace node.</param>
  684. /// <returns>Always returns false for the HtmlNavigator implementation.</returns>
  685. public override bool MoveToNamespace(string name)
  686. {
  687. InternalTrace("name=" + name);
  688. return false;
  689. }
  690. /// <summary>
  691. /// Moves the XPathNavigator to the first namespace node of the current element.
  692. /// Always returns false for the HtmlNavigator implementation.
  693. /// </summary>
  694. /// <param name="scope">An XPathNamespaceScope value describing the namespace scope.</param>
  695. /// <returns>Always returns false for the HtmlNavigator implementation.</returns>
  696. public override bool MoveToFirstNamespace(XPathNamespaceScope scope)
  697. {
  698. InternalTrace(null);
  699. return false;
  700. }
  701. /// <summary>
  702. /// Moves the XPathNavigator to the next namespace node.
  703. /// Always returns falsefor the HtmlNavigator implementation.
  704. /// </summary>
  705. /// <param name="scope">An XPathNamespaceScope value describing the namespace scope.</param>
  706. /// <returns>Always returns false for the HtmlNavigator implementation.</returns>
  707. public override bool MoveToNextNamespace(XPathNamespaceScope scope)
  708. {
  709. InternalTrace(null);
  710. return false;
  711. }
  712. /// <summary>
  713. /// Gets the current HTML node.
  714. /// </summary>
  715. public HtmlNode CurrentNode
  716. {
  717. get
  718. {
  719. return _currentnode;
  720. }
  721. }
  722. /// <summary>
  723. /// Gets the current HTML document.
  724. /// </summary>
  725. public HtmlDocument CurrentDocument
  726. {
  727. get
  728. {
  729. return _doc;
  730. }
  731. }
  732. }
  733. }