ExtensionsTest.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. //
  2. // Author:
  3. // Atsushi Enomoto <[email protected]>
  4. //
  5. // Copyright (C) 2010 Novell, Inc.
  6. // (C) 2003 Atsushi Enomoto <[email protected]>
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. //
  28. // (based on XPathNavigatorCommonTests)
  29. //
  30. using System;
  31. using System.Collections;
  32. using System.IO;
  33. using System.Linq;
  34. using System.Xml;
  35. using System.Xml.Linq;
  36. using System.Xml.XPath;
  37. using NUnit.Framework;
  38. using System.Collections.Generic;
  39. namespace MonoTests.System.Xml
  40. {
  41. public static class Helpers
  42. {
  43. public static string NormalizeNewline(this string str)
  44. {
  45. return str.Replace("\r\n", "\n");
  46. }
  47. }
  48. [TestFixture]
  49. public class ExtensionsTest
  50. {
  51. XPathNavigator nav;
  52. private void AssertNavigator (string label, XPathNavigator nav, XPathNodeType type, string prefix, string localName, string ns, string name, string value, bool hasAttributes, bool hasChildren, bool isEmptyElement)
  53. {
  54. label += nav.GetType ();
  55. Assert.AreEqual (type, nav.NodeType, label + "NodeType");
  56. Assert.AreEqual (prefix, nav.Prefix, label + "Prefix");
  57. Assert.AreEqual (localName, nav.LocalName, label + "LocalName");
  58. Assert.AreEqual (ns, nav.NamespaceURI, label + "Namespace");
  59. Assert.AreEqual (name, nav.Name, label + "Name");
  60. Assert.AreEqual (value, nav.Value, label + "Value");
  61. Assert.AreEqual (hasAttributes, nav.HasAttributes, label + "HasAttributes");
  62. Assert.AreEqual (hasChildren, nav.HasChildren, label + "HasChildren");
  63. Assert.AreEqual (isEmptyElement, nav.IsEmptyElement, label + "IsEmptyElement");
  64. }
  65. [Test]
  66. public void DocumentWithXmlDeclaration ()
  67. {
  68. string xml = "<?xml version=\"1.0\" standalone=\"yes\"?><foo>bar</foo>";
  69. nav = XDocument.Parse (xml).CreateNavigator ();
  70. DocumentWithXmlDeclaration (nav);
  71. }
  72. public void DocumentWithXmlDeclaration (XPathNavigator nav)
  73. {
  74. nav.MoveToFirstChild ();
  75. AssertNavigator ("#1", nav, XPathNodeType.Element, "", "foo", "", "foo", "bar", false, true, false);
  76. }
  77. [Test]
  78. public void DocumentWithProcessingInstruction ()
  79. {
  80. string xml = "<?xml-stylesheet href='foo.xsl' type='text/xsl' ?><foo />";
  81. nav = XDocument.Parse (xml).CreateNavigator ();
  82. DocumentWithProcessingInstruction (nav);
  83. }
  84. public void DocumentWithProcessingInstruction (XPathNavigator nav)
  85. {
  86. Assert.IsTrue (nav.MoveToFirstChild ());
  87. AssertNavigator ("#1", nav, XPathNodeType.ProcessingInstruction, "", "xml-stylesheet", "", "xml-stylesheet", "href='foo.xsl' type='text/xsl' ", false, false, false);
  88. Assert.IsTrue (!nav.MoveToFirstChild ());
  89. }
  90. [Test]
  91. public void XmlRootElementOnly ()
  92. {
  93. string xml = "<foo />";
  94. nav = XDocument.Parse (xml).CreateNavigator ();
  95. XmlRootElementOnly (nav);
  96. }
  97. private void XmlRootElementOnly (XPathNavigator nav)
  98. {
  99. AssertNavigator ("#1", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
  100. Assert.IsTrue (nav.MoveToFirstChild ());
  101. AssertNavigator ("#2", nav, XPathNodeType.Element, "", "foo", "", "foo", "", false, false, true);
  102. Assert.IsTrue (!nav.MoveToFirstChild ());
  103. Assert.IsTrue (!nav.MoveToNext ());
  104. Assert.IsTrue (!nav.MoveToPrevious ());
  105. nav.MoveToRoot ();
  106. AssertNavigator ("#3", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
  107. Assert.IsTrue (!nav.MoveToNext ());
  108. }
  109. [Test]
  110. public void XmlSimpleTextContent ()
  111. {
  112. string xml = "<foo>Test.</foo>";
  113. nav = XDocument.Parse (xml).CreateNavigator ();
  114. XmlSimpleTextContent (nav);
  115. }
  116. private void XmlSimpleTextContent (XPathNavigator nav)
  117. {
  118. AssertNavigator ("#1", nav, XPathNodeType.Root, "", "", "", "", "Test.", false, true, false);
  119. Assert.IsTrue (nav.MoveToFirstChild (), "#x1");
  120. AssertNavigator ("#2", nav, XPathNodeType.Element, "", "foo", "", "foo", "Test.", false, true, false);
  121. Assert.IsTrue (!nav.MoveToNext (), "#x2");
  122. Assert.IsTrue (!nav.MoveToPrevious (), "#x3");
  123. Assert.IsTrue (nav.MoveToFirstChild (), "#x4");
  124. AssertNavigator ("#3", nav, XPathNodeType.Text, "", "", "", "", "Test.", false, false, false);
  125. Assert.IsTrue (nav.MoveToParent (), "#x5");
  126. AssertNavigator ("#4", nav, XPathNodeType.Element, "", "foo", "", "foo", "Test.", false, true, false);
  127. Assert.IsTrue (nav.MoveToParent (), "#x6");
  128. AssertNavigator ("#5", nav, XPathNodeType.Root, "", "", "", "", "Test.", false, true, false);
  129. nav.MoveToFirstChild ();
  130. nav.MoveToFirstChild ();
  131. nav.MoveToRoot ();
  132. AssertNavigator ("#6", nav, XPathNodeType.Root, "", "", "", "", "Test.", false, true, false);
  133. Assert.IsTrue (!nav.MoveToNext (), "#x7");
  134. }
  135. [Test]
  136. public void XmlSimpleElementContent ()
  137. {
  138. string xml = "<foo><bar /></foo>";
  139. nav = XDocument.Parse (xml).CreateNavigator ();
  140. XmlSimpleElementContent (nav);
  141. }
  142. private void XmlSimpleElementContent (XPathNavigator nav)
  143. {
  144. AssertNavigator ("#1", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
  145. Assert.IsTrue (nav.MoveToFirstChild ());
  146. AssertNavigator ("#2", nav, XPathNodeType.Element, "", "foo", "", "foo", "", false, true, false);
  147. Assert.IsTrue (!nav.MoveToNext ());
  148. Assert.IsTrue (!nav.MoveToPrevious ());
  149. Assert.IsTrue (nav.MoveToFirstChild ());
  150. AssertNavigator ("#3", nav, XPathNodeType.Element, "", "bar", "", "bar", "", false, false, true);
  151. Assert.IsTrue (nav.MoveToParent ());
  152. AssertNavigator ("#4", nav, XPathNodeType.Element, "", "foo", "", "foo", "", false, true, false);
  153. nav.MoveToRoot ();
  154. AssertNavigator ("#5", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
  155. Assert.IsTrue (!nav.MoveToNext ());
  156. }
  157. [Test]
  158. public void XmlTwoElementsContent ()
  159. {
  160. string xml = "<foo><bar /><baz /></foo>";
  161. nav = XDocument.Parse (xml).CreateNavigator ();
  162. XmlTwoElementsContent (nav);
  163. }
  164. private void XmlTwoElementsContent (XPathNavigator nav)
  165. {
  166. AssertNavigator ("#1", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
  167. Assert.IsTrue (nav.MoveToFirstChild ());
  168. AssertNavigator ("#2", nav, XPathNodeType.Element, "", "foo", "", "foo", "", false, true, false);
  169. Assert.IsTrue (!nav.MoveToNext ());
  170. Assert.IsTrue (!nav.MoveToPrevious ());
  171. Assert.IsTrue (nav.MoveToFirstChild ());
  172. AssertNavigator ("#3", nav, XPathNodeType.Element, "", "bar", "", "bar", "", false, false, true);
  173. Assert.IsTrue (!nav.MoveToFirstChild ());
  174. Assert.IsTrue (nav.MoveToNext ());
  175. AssertNavigator ("#4", nav, XPathNodeType.Element, "", "baz", "", "baz", "", false, false, true);
  176. Assert.IsTrue (!nav.MoveToFirstChild ());
  177. Assert.IsTrue (nav.MoveToPrevious ());
  178. AssertNavigator ("#5", nav, XPathNodeType.Element, "", "bar", "", "bar", "", false, false, true);
  179. nav.MoveToRoot ();
  180. AssertNavigator ("#6", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
  181. Assert.IsTrue (!nav.MoveToNext ());
  182. }
  183. [Test]
  184. public void XmlElementWithAttributes ()
  185. {
  186. string xml = "<img src='foo.png' alt='image Fooooooo!' />";
  187. nav = XDocument.Parse (xml).CreateNavigator ();
  188. XmlElementWithAttributes (nav);
  189. }
  190. private void XmlElementWithAttributes (XPathNavigator nav)
  191. {
  192. nav.MoveToFirstChild ();
  193. AssertNavigator ("#1", nav, XPathNodeType.Element, "", "img", "", "img", "", true, false, true);
  194. Assert.IsTrue (!nav.MoveToNext (), "#x1");
  195. Assert.IsTrue (!nav.MoveToPrevious (), "#x2");
  196. Assert.IsTrue (nav.MoveToFirstAttribute (), "#x3");
  197. AssertNavigator ("#2", nav, XPathNodeType.Attribute, "", "src", "", "src", "foo.png", false, false, false);
  198. Assert.IsTrue (!nav.MoveToFirstAttribute (), "#x4"); // On attributes, it fails.
  199. Assert.IsTrue (nav.MoveToNextAttribute (), "#x5");
  200. AssertNavigator ("#3", nav, XPathNodeType.Attribute, "", "alt", "", "alt", "image Fooooooo!", false, false, false);
  201. Assert.IsTrue (!nav.MoveToNextAttribute (), "#x6");
  202. Assert.IsTrue (nav.MoveToParent (), "#x7");
  203. AssertNavigator ("#4", nav, XPathNodeType.Element, "", "img", "", "img", "", true, false, true);
  204. Assert.IsTrue (nav.MoveToAttribute ("alt", ""), "#x8");
  205. AssertNavigator ("#5", nav, XPathNodeType.Attribute, "", "alt", "", "alt", "image Fooooooo!", false, false, false);
  206. Assert.IsTrue (!nav.MoveToAttribute ("src", ""), "#x9"); // On attributes, it fails.
  207. Assert.IsTrue (nav.MoveToParent (), "#x10");
  208. Assert.IsTrue (nav.MoveToAttribute ("src", ""), "#x11");
  209. AssertNavigator ("#6", nav, XPathNodeType.Attribute, "", "src", "", "src", "foo.png", false, false, false);
  210. nav.MoveToRoot ();
  211. AssertNavigator ("#7", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
  212. }
  213. [Test]
  214. // seems like MS does not want to fix their long-time-known
  215. // XPathNavigator bug, so just set it as NotDotNet.
  216. // We are better.
  217. [Category ("NotDotNet")]
  218. public void XmlNamespaceNode ()
  219. {
  220. string xml = "<html xmlns='http://www.w3.org/1999/xhtml'><body>test.</body></html>";
  221. nav = XDocument.Parse (xml).CreateNavigator ();
  222. XmlNamespaceNode (nav);
  223. }
  224. private void XmlNamespaceNode (XPathNavigator nav)
  225. {
  226. string xhtml = "http://www.w3.org/1999/xhtml";
  227. string xmlNS = "http://www.w3.org/XML/1998/namespace";
  228. nav.MoveToFirstChild ();
  229. AssertNavigator ("#1", nav, XPathNodeType.Element,
  230. "", "html", xhtml, "html", "test.", false, true, false);
  231. Assert.IsTrue (nav.MoveToFirstNamespace (XPathNamespaceScope.Local));
  232. AssertNavigator ("#2", nav, XPathNodeType.Namespace,
  233. "", "", "", "", xhtml, false, false, false);
  234. // Test difference between Local, ExcludeXml and All.
  235. Assert.IsTrue (!nav.MoveToNextNamespace (XPathNamespaceScope.Local));
  236. Assert.IsTrue (!nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml));
  237. // LAMESPEC: MS.NET 1.0 XmlDocument seems to have some bugs around here.
  238. // see http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q316808
  239. #if true
  240. Assert.IsTrue (nav.MoveToNextNamespace (XPathNamespaceScope.All));
  241. AssertNavigator ("#3", nav, XPathNodeType.Namespace,
  242. "", "xml", "", "xml", xmlNS, false, false, false);
  243. Assert.IsTrue (!nav.MoveToNextNamespace (XPathNamespaceScope.All));
  244. #endif
  245. // Test to check if MoveToRoot() resets Namespace node status.
  246. nav.MoveToRoot ();
  247. AssertNavigator ("#4", nav, XPathNodeType.Root, "", "", "", "", "test.", false, true, false);
  248. nav.MoveToFirstChild ();
  249. // Test without XPathNamespaceScope argument.
  250. Assert.IsTrue (nav.MoveToFirstNamespace ());
  251. Assert.IsTrue (nav.MoveToNextNamespace ());
  252. AssertNavigator ("#5", nav, XPathNodeType.Namespace,
  253. "", "xml", "", "xml", xmlNS, false, false, false);
  254. // Test MoveToParent()
  255. Assert.IsTrue (nav.MoveToParent ());
  256. AssertNavigator ("#6", nav, XPathNodeType.Element,
  257. "", "html", xhtml, "html", "test.", false, true, false);
  258. nav.MoveToFirstChild (); // body
  259. // Test difference between Local and ExcludeXml
  260. Assert.IsTrue (!nav.MoveToFirstNamespace (XPathNamespaceScope.Local), "Local should fail");
  261. Assert.IsTrue (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml), "ExcludeXml should succeed");
  262. AssertNavigator ("#7", nav, XPathNodeType.Namespace,
  263. "", "", "", "", xhtml, false, false, false);
  264. Assert.IsTrue (nav.MoveToNextNamespace (XPathNamespaceScope.All));
  265. AssertNavigator ("#8", nav, XPathNodeType.Namespace,
  266. "", "xml", "", "xml", xmlNS, false, false, false);
  267. Assert.IsTrue (nav.MoveToParent ());
  268. AssertNavigator ("#9", nav, XPathNodeType.Element,
  269. "", "body", xhtml, "body", "test.", false, true, false);
  270. nav.MoveToRoot ();
  271. AssertNavigator ("#10", nav, XPathNodeType.Root, "", "", "", "", "test.", false, true, false);
  272. }
  273. [Test]
  274. public void MoveToNamespaces ()
  275. {
  276. string xml = "<a xmlns:x='urn:x'><b xmlns:y='urn:y'/><c/><d><e attr='a'/></d></a>";
  277. nav = XDocument.Parse (xml).CreateNavigator ();
  278. MoveToNamespaces (nav);
  279. }
  280. private void MoveToNamespaces (XPathNavigator nav)
  281. {
  282. XPathNodeIterator iter = nav.Select ("//e");
  283. iter.MoveNext ();
  284. nav.MoveTo (iter.Current);
  285. Assert.AreEqual ("e", nav.Name, "#1");
  286. nav.MoveToFirstNamespace ();
  287. Assert.AreEqual ("x", nav.Name, "#2");
  288. nav.MoveToNextNamespace ();
  289. Assert.AreEqual ("xml", nav.Name, "#3");
  290. }
  291. [Test]
  292. public void IsDescendant ()
  293. {
  294. string xml = "<a><b/><c/><d><e attr='a'/></d></a>";
  295. nav = XDocument.Parse (xml).CreateNavigator ();
  296. IsDescendant (nav);
  297. }
  298. private void IsDescendant (XPathNavigator nav)
  299. {
  300. XPathNavigator tmp = nav.Clone ();
  301. XPathNodeIterator iter = nav.Select ("//e");
  302. iter.MoveNext ();
  303. Assert.IsTrue (nav.MoveTo (iter.Current), "#1");
  304. Assert.IsTrue (nav.MoveToFirstAttribute (), "#2");
  305. Assert.AreEqual ("attr", nav.Name, "#3");
  306. Assert.AreEqual ("", tmp.Name, "#4");
  307. Assert.IsTrue (tmp.IsDescendant (nav), "#5");
  308. Assert.IsTrue (!nav.IsDescendant (tmp), "#6");
  309. tmp.MoveToFirstChild ();
  310. Assert.AreEqual ("a", tmp.Name, "#7");
  311. Assert.IsTrue (tmp.IsDescendant (nav), "#8");
  312. Assert.IsTrue (!nav.IsDescendant (tmp), "#9");
  313. tmp.MoveTo (iter.Current);
  314. Assert.AreEqual ("e", tmp.Name, "#10");
  315. Assert.IsTrue (tmp.IsDescendant (nav), "#11");
  316. Assert.IsTrue (!nav.IsDescendant (tmp), "#12");
  317. }
  318. [Test]
  319. public void LiterallySplitText ()
  320. {
  321. string xml = "<root><![CDATA[test]]> string</root>";
  322. nav = XDocument.Parse (xml).CreateNavigator ();
  323. LiterallySplitText (nav);
  324. }
  325. private void LiterallySplitText (XPathNavigator nav)
  326. {
  327. nav.MoveToFirstChild ();
  328. nav.MoveToFirstChild ();
  329. Assert.AreEqual (XPathNodeType.Text, nav.NodeType, "#1");
  330. Assert.AreEqual ("test string", nav.Value, "#2");
  331. }
  332. // bug #75609
  333. [Test]
  334. public void SelectChildren ()
  335. {
  336. string xml = "<root><foo xmlns='urn:foo' /><ns:foo xmlns:ns='urn:foo' /></root>";
  337. nav = XDocument.Parse (xml).CreateNavigator ();
  338. SelectChildrenNS (nav);
  339. }
  340. private void SelectChildrenNS (XPathNavigator nav)
  341. {
  342. nav.MoveToFirstChild (); // root
  343. XPathNodeIterator iter = nav.SelectChildren ("foo", "urn:foo");
  344. Assert.AreEqual (2, iter.Count, "#1");
  345. }
  346. #if NET_2_0
  347. [Test]
  348. // bug #78067
  349. public void OuterXml ()
  350. {
  351. string xml = @"<?xml version=""1.0""?>
  352. <one>
  353. <two>Some data.</two>
  354. </one>";
  355. nav = XDocument.Parse (xml).CreateNavigator ();
  356. OuterXml (nav);
  357. }
  358. private void OuterXml (XPathNavigator nav)
  359. {
  360. string ret = @"<one>
  361. <two>Some data.</two>
  362. </one>";
  363. Assert.AreEqual (ret.NormalizeNewline (), nav.OuterXml.NormalizeNewline (), "#1");
  364. }
  365. [Test]
  366. public void ReadSubtreeLookupNamespace ()
  367. {
  368. string xml = "<x:foo xmlns:x='urn:x'><bar>x:val</bar></x:foo>";
  369. var doc = new XmlDocument ();
  370. doc.LoadXml (xml);
  371. XPathNavigator nav = doc.LastChild.LastChild.CreateNavigator ();
  372. var xr = nav.ReadSubtree ();
  373. xr.MoveToContent ();
  374. xr.Read (); // should be at x:val
  375. Assert.AreEqual ("urn:x", xr.LookupNamespace ("x"), "#1");
  376. }
  377. #endif
  378. [Test]
  379. public void GetNamespaceConsistentTree ()
  380. {
  381. string xml = "<x:root xmlns:x='urn:x'> <x:foo xmlns='ns1'> <x:bar /> </x:foo> <x:foo xmlns:y='ns2'> <x:bar /> </x:foo></x:root>";
  382. nav = XDocument.Parse (xml).CreateNavigator ();
  383. GetNamespaceConsistentTree (nav);
  384. }
  385. private void GetNamespaceConsistentTree (XPathNavigator nav)
  386. {
  387. nav.MoveToFirstChild ();
  388. nav.MoveToFirstChild ();
  389. nav.MoveToNext ();
  390. Assert.AreEqual (String.Empty, nav.GetNamespace (""), "#1." + nav.GetType ());
  391. nav.MoveToNext ();
  392. nav.MoveToNext ();
  393. Assert.AreEqual ("", nav.GetNamespace (""), "#2." + nav.GetType ());
  394. }
  395. [Test] // bug #2383
  396. public void EvaluateNodeSetAsEnumerable ()
  397. {
  398. String xml = "<root a='value'/>";
  399. XDocument d = XDocument.Parse (xml);
  400. IEnumerable att = (IEnumerable) d.XPathEvaluate ("/root/@a");
  401. att.Cast<XAttribute> ().FirstOrDefault ();
  402. }
  403. [Test] // bug #5902
  404. public void EvaluateNodeSetAsEnumerableOfObject ()
  405. {
  406. var root = XDocument.Parse("<config><item name=\"A\" /></config>");
  407. Assert.IsTrue (root.XPathSelectElements ("config/*").First ().XPathEvaluate (".") is IEnumerable<object>);
  408. }
  409. [Test] // bug #2146
  410. public void RemoveDoesSnapshotCopy ()
  411. {
  412. var xml = XElement.Parse ("<p><n>one</n><n>two</n><n>three</n></p>");
  413. xml.Elements ().Last ().NodesBeforeSelf ().Remove ();
  414. }
  415. [Test] // bug #2146
  416. public void RemoveDoesSnapshotCopy2 ()
  417. {
  418. var xml = XElement.Parse ("<p><n>one</n><n>two</n><n>three</n></p>");
  419. xml.Elements ().First ().NodesAfterSelf ().Remove ();
  420. Assert.IsTrue (!xml.ToString ().Contains ("three"), "#1");
  421. }
  422. }
  423. }