public void PreservesImmutability() { IXML xml = new XMLCursor("<r1><a/></r1>"); XNode node = xml.Nodes("/r1/a")[0].AsNode(); node.Remove(); Assert.Single( xml.Nodes("/r1/a") ); }
public void RetrievesDomNode() { IXML doc = new XMLCursor("<root><simple>hello</simple></root>"); Assert.Equal( "<simple>hello</simple>", doc.Nodes("/root/simple")[0].AsNode().ToString() ); Assert.Equal <XmlNodeType>( XmlNodeType.Element, doc.Nodes("//simple")[0].AsNode().NodeType ); }
public void ContainsOnlyQueriedNodes() { IXML xml = new XMLCursor("<t6><z9 a='433'><item>a</item><item>b</item></z9><z9 a='432'><item>c</item></z9></t6>"); IXML root = xml.Nodes("/t6/z9[@a='433']")[0]; Assert.Empty(root.Values("/z9[@a='432']")); }
public void FindsNodesWithBuiltinNamespace() { IXML doc = new XMLCursor( "<html xmlns='http://www.w3.org/1999/xhtml'><div>\u0443\u0440\u0430!</div></html>" ); Assert.Equal( 1, doc.Nodes("/xhtml:html/xhtml:div").Count ); Assert.Equal( 1, doc.Nodes("//xhtml:div[.='\u0443\u0440\u0430!']").Count ); }
public void FindsDocumentNodesWithXpath() { IXML doc = new XMLCursor( new Yaapii.Atoms.IO.InputOf( "<root><a><x>1</x></a><a><x>2</x></a></root>" ) ); Assert.Equal( 2, doc.Nodes("//a").Count ); Assert.Equal( "1", doc.Nodes("/root/a")[0].Values("x/text()")[0] ); }
public void AppliesXpathToClonedNode() { IXML xml = new XMLCursor("<t6><z9 a='433'/></t6>"); IXML root = xml.Nodes("/t6")[0]; Assert.Equal( "433", root.Values("//z9/@a")[0] ); }
public void PreservesNodeWhenAccessingValue() { IXML xml = new XMLCursor("<r1><a><b>1</b></a><a><b>2</b></a></r1>"); foreach (var node in xml.Nodes("/r1/a/b")) { //This was a usecase where the bug occured. Count was 1. Assert.Equal(0, node.Values("/b/text()").Count); } }
public void NodesCanBeInterlaced() { IXML doc = new XMLCursor( "<root><item1><subitem1/></item1><item2/><item3/></root>"); Assert.Equal( "subitem1", doc.Nodes("/root/item1")[0].Nodes("./subitem1")[0].Values("name()")[0] ); }
public void BuildsDomNode() { IXML doc = new XMLCursor("<?xml version='1.0'?><f/>"); Assert.True( doc.AsNode().NodeType == XmlNodeType.Document ); Assert.True( doc.Nodes("/f")[0].AsNode().NodeType == XmlNodeType.Element ); }
public void PrintsWithAndWithoutXmlHeader() { IXML doc = new XMLCursor("<hey/>"); Assert.Contains( "<?xml", doc.ToString()); Assert.StartsWith( "<hey", doc.Nodes("/*")[0].ToString()); }
public void PreservesDomStructureWhenXpath() { IXML doc = new XMLCursor( "<root><item1/><item2/><item3/></root>" ); IXML item = doc.Nodes("/root/item2")[0]; Assert.Equal( "root", item.Nodes("..")[0].Values("name()")[0]); }
public void FindsDocumentNodes() { IXML doc = new XMLCursor( new InputOf( "<root><a><x attr='test'>1</x></a><a><x>2</x></a></root>" ) ); Assert.True( new Atoms.Enumerable.LengthOf( doc.Nodes("//a") ).Value() == 2 ); }
public void FindsDocumentValues() { IXML doc = new XMLCursor( new InputOf( "<root><a><x attr='test'>1</x></a><a><x>2</x></a></root>" ) ); Assert.True( doc .Nodes("/root/a")[0] .Values("x/@attr")[0] == "test" ); }
public void FindsNodesWithCustomNamespace() { IXML doc = new XMLCursor( "<a xmlns='urn:foo'><b>\u0433!</b></a>" ); doc = doc.WithNamespace("f", "urn:foo"); Assert.Single( doc.Nodes("/f:a/f:b[.='\u0433!']") ); Assert.Equal( "\u0433!", doc.Values("//f:b/text()")[0] ); }