Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Jan 27, 2006 5:03 am Post subject: How do I bind to an Xml Document |
|
|
You can bind to an XML document using Object Binding. To do this you create an Object binding for the System.Xml.XmlNode class (which XmlDocument derives from). However due to the fact that the System.Xml.XmlNode class is implemented as wrapper around COM objects you need to enter the fully qualified .NET type name - otherwise the .NET type system is unable to load the type. For VS2003 this is:
System.Xml.XmlNode, System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
The XmlNodeList type returned by XmlNode.ChildNodes property does not support the IList interface (only IEnumerable). This means you also have to handle the GetChildren event and convert the child nodes to a standard array list as follows:
Code: | private void _virtualTree_GetChildren(object sender, Infralution.Controls.VirtualTree.GetChildrenEventArgs e)
{
XmlNode node = e.Row.Item as XmlNode;
ArrayList children = new ArrayList();
foreach (XmlNode child in node.ChildNodes)
{
children.Add(child);
}
e.Children = children;
} |
_________________ Infralution Support |
|