Пример #1
0
 private void FillTree()
 {
     if (TxtScrapbookDataPath.Text != "")
     {
         string str         = string.Concat(TxtScrapbookDataPath.Text, "\\scrapbook.rdf");
         var    xmlDocument = new XmlDocument();
         xmlDocument.Load(str);
         TreeModelList.Clear();
         AddItemToList(null, xmlDocument.DocumentElement, "urn:scrapbook:root");
         MyTree.ItemsSourceData = TreeModelList;
     }
 }
Пример #2
0
        private void AddItemToList(TreeModel tn, XmlNode parent, string about)
        {
            XmlNode xmlNode = SeqNode(parent, about);

            if (xmlNode == null)
            {
                return;
            }
            foreach (XmlNode xmlNode2 in xmlNode.ChildNodes)
            {
                if (xmlNode2.Name == "RDF:li")
                {
                    TreeModel treeModel;
                    if (tn == null)
                    {
                        XmlNode node           = DefNode(parent, xmlNode2.Attributes["RDF:resource"].Value);
                        string  attributeValue = GetAttributeValue(node, "title");
                        treeModel      = new TreeModel();
                        treeModel.Name = attributeValue;
                        treeModel.Id   = GetAttributeValue(node, "id");
                        TreeModelList.Add(treeModel);
                    }
                    else
                    {
                        XmlNode node            = DefNode(parent, xmlNode2.Attributes["RDF:resource"].Value);
                        string  attributeValue2 = GetAttributeValue(node, "title");
                        treeModel        = new TreeModel();
                        treeModel.Name   = attributeValue2;
                        treeModel.Id     = GetAttributeValue(node, "id");
                        treeModel.Parent = tn;
                        tn.Children.Add(treeModel);
                    }
                    AddItemToList(treeModel, parent, xmlNode2.Attributes["RDF:resource"].Value);
                }
            }
        }