I am having a problem fixing this error: Object reference not set to an instance of an object,
namespace FaultTrees
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.LoadXML();
}
private void LoadXML()
{
List<FaultTree> faultTrees = new List<FaultTree>();
XDocument FaultTreeXML = XDocument.Load("testtrees.xml");
faultTrees = this.GetFaultTrees(FaultTreeXML.Element("HiP-HOPS_Results"));
this.TreeView.ItemsSource = faultTrees;
}
private List<FaultTree> GetFaultTrees(XElement element)
{
return (from faultTree in element.Elements("FaultTrees")
select [B]new FaultTree()
{
Name = faultTree.Attribute("Events").Value,
SubCategories = this.GetFaultTrees(faultTree)
}).ToList();[/B]
}
}
}
the bold section is where it is tripping up, any help would be appreciated