XmlData GetDescendant Method (String)Delta Engine Documentation

Namespace: DeltaEngine.Content.Xml
Assembly: DeltaEngine.Content.Xml (in DeltaEngine.Content.Xml.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public XmlData GetDescendant(
	string childName
)

Return Value

Type: XmlData
Remarks

Tests: DeltaEngine.Content.Xml.Tests.XmlDataTests
Examples

6 unit tests call DeltaEngine.Content.Xml.XmlData.GetDescendant(System.String)
[Test]
public void GetDescendant()
{
    XmlData root = CreateDeepTestXmlData();
    Assert.AreEqual(root.Children[1], root.GetDescendant(root.Children[1].Name));
    Assert.AreEqual(root.Children[1].Children[0], root.GetDescendant("grandchild"));
    Assert.AreEqual(null, root.GetDescendant("unknown"));
}
[Test]
public void GetDescendantWithAttribute()
{
    XmlData root = CreateDeepTestXmlData();
    Assert.AreEqual(root.Children[0], root.GetDescendant(new XmlAttribute("Attr1", "Value1")));
    Assert.AreEqual(root.Children[1].Children[0],
        root.GetDescendant(new XmlAttribute("Attr5", "Value5")));
    Assert.AreEqual(null, root.GetDescendant(new XmlAttribute("Attr5", "Value6")));
    Assert.AreEqual(null, root.GetDescendant(new XmlAttribute("Attr6", "Value5")));
}
[Test]
public void GetDescendantWithAttributeAndName()
{
    XmlData root = CreateDeepTestXmlData();
    Assert.AreEqual(root.Children[0],
        root.GetDescendant(new XmlAttribute("Attr1", "Value1"), root.Children[0].Name));
    Assert.AreEqual(null,
        root.GetDescendant(new XmlAttribute("Attr1", "Value1"), root.Children[1].Name));
}
See Also