Model.Load()

Hi,

I saw a line written in xaml contructor of each sample:

model.Load(XElement.Parse(xml), “Employee”);

this loads the xml but only till Level-1. (ex: Root --> Employee). But my xml structure is something like:



                     <Member name="">
         ......
    </Members>
</Unit>
......

When I use the method Load defined in OrgChartEditor constructor, it loads just Root and Unit nodes coz method is taking only two nodes as parameter. What do I have to do so that it loads all the nodes available in the XML. I want to create a generic method to load all the elements.

Thanks,
Manish

I got my answer myself!! :)

For anyone else reading this post, you’ll want to do something like:

model.StartTransaction("Load"); var nodedata = new ObservableCollection<MyNodeData>(); foreach (XElement xe in xdoc.Descendants("Member")) { var d = new MyNodeData(); d.LoadFromXElement(xe); nodedata.Add(d); } model.NodesSource = nodedata; model.CommitTransaction("Load");
Linq to XML is so much easier to use than System.Xml.