Exemplo n.º 1
0
 /// <summary>
 /// Adds child elements to this tree node.
 /// </summary>
 protected override void Initialize()
 {
     Nodes.Clear();
     foreach (XmlNode childNode in element.ChildNodes)
     {
         XmlElement childElement = childNode as XmlElement;
         XmlText    text         = childNode as XmlText;
         XmlComment comment      = childNode as XmlComment;
         if (childElement != null)
         {
             XmlElementTreeNode treeNode = new XmlElementTreeNode(childElement);
             treeNode.AddTo(this);
         }
         else if (text != null)
         {
             XmlTextTreeNode treeNode = new XmlTextTreeNode(text);
             treeNode.AddTo(this);
         }
         else if (comment != null)
         {
             XmlCommentTreeNode treeNode = new XmlCommentTreeNode(comment);
             treeNode.AddTo(this);
         }
     }
 }
        /// <summary>
        /// Appends a new child text node to the currently selected element.
        /// </summary>
        public void AppendChildTextNode(XmlText textNode)
        {
            XmlElementTreeNode selectedNode = SelectedElementNode;

            if (selectedNode != null)
            {
                XmlTextTreeNode newNode = new XmlTextTreeNode(textNode);
                newNode.AddTo(selectedNode);
                selectedNode.Expand();
            }
        }
		/// <summary>
		/// Adds child elements to this tree node.
		/// </summary>
		protected override void Initialize()
		{
			Nodes.Clear();
			foreach (XmlNode childNode in element.ChildNodes) {
				XmlElement childElement = childNode as XmlElement;
				XmlText text = childNode as XmlText;
				XmlComment comment = childNode as XmlComment;
				if (childElement != null) {
					XmlElementTreeNode treeNode = new XmlElementTreeNode(childElement);
					treeNode.AddTo(this);
				} else if (text != null) {
					XmlTextTreeNode treeNode = new XmlTextTreeNode(text);
					treeNode.AddTo(this);
				} else if (comment != null) {
					XmlCommentTreeNode treeNode = new XmlCommentTreeNode(comment);
					treeNode.AddTo(this);
				}
			}
		}
		/// <summary>
		/// Appends a new child text node to the currently selected element.
		/// </summary>
		public void AppendChildTextNode(XmlText textNode)
		{
			XmlElementTreeNode selectedNode = SelectedElementNode;
			if (selectedNode != null) {
				XmlTextTreeNode newNode = new XmlTextTreeNode(textNode);
				newNode.AddTo(selectedNode);
				selectedNode.Expand();
			}
		}