public XmlAttributeTreeNode CreateAttribute(System.Xml.XmlAttribute oXmlAttribute) { XmlAttributeTreeNode oXmlAttributeTreeNode = new XmlAttributeTreeNode(oXmlAttribute.Name, oXmlAttribute.Name, oXmlAttribute.Value, 1, 1); oXmlAttributeTreeNode.Nodes.Add(new XmlTextTreeNode(oXmlAttribute.Value, 2, 2)); return(oXmlAttributeTreeNode); }
public void InsertAttributeAfter(XmlAttributeTreeNode oNewTreeNode) { if (this.SelectedNode is XmlAttributeTreeNode || this.SelectedNode is XmlTextTreeNode) { if (this.SelectedNode is XmlAttributeTreeNode) { this.SelectedNode.Parent.Nodes.Insert(this.SelectedNode.Index + 1, oNewTreeNode); } else if (this.SelectedNode is XmlTextTreeNode) { this.SelectedNode.Parent.Parent.Nodes.Insert(this.SelectedNode.Index + 1, oNewTreeNode); } this.SelectedNode = oNewTreeNode; Updated = true; } }
public void AddAttribute(XmlAttributeTreeNode oNewTreeNode) { TreeNode oTreeNodeBase = GetTreeNodeBaseForAttribute(); if (oTreeNodeBase != null) { this.SelectedNode.Nodes.Insert(oTreeNodeBase.Index, oNewTreeNode); } else { this.SelectedNode.Nodes.Add(oNewTreeNode); } this.SelectedNode = oNewTreeNode; Updated = true; }
public void UpdateAttribute(XmlAttributeTreeNode oNewTreeNode) { if (this.SelectedNode is XmlAttributeTreeNode || this.SelectedNode is XmlTextTreeNode) { if (this.SelectedNode is XmlAttributeTreeNode) { TreeNode select = this.SelectedNode; this.SelectedNode.Parent.Nodes.Insert(this.SelectedNode.Index, oNewTreeNode); this.Nodes.Remove(select); this.SelectedNode = oNewTreeNode; Updated = true; } else if (this.SelectedNode is XmlTextTreeNode) { TreeNode select = this.SelectedNode.Parent; this.SelectedNode.Parent.Parent.Nodes.Insert(this.SelectedNode.Parent.Index, oNewTreeNode); this.Nodes.Remove(select); this.SelectedNode = oNewTreeNode; Updated = true; } } }
public XmlElementTreeNode CreateElement(System.Xml.XmlNode oXmlNode) { XmlElementTreeNode oXmlElementTreeNode = new XmlElementTreeNode(); switch (oXmlNode.NodeType) { case System.Xml.XmlNodeType.Document: break; case System.Xml.XmlNodeType.Element: oXmlElementTreeNode.Name = oXmlNode.Name; oXmlElementTreeNode.Text = oXmlNode.Name; if (oXmlNode.Attributes != null) { if (oXmlNode.Attributes.Count > 0) { foreach (System.Xml.XmlAttribute oXmlAttribute in oXmlNode.Attributes) { XmlAttributeTreeNode oXmlAttributeTreeNode = new XmlAttributeTreeNode(oXmlAttribute.Name, oXmlAttribute.Name, oXmlAttribute.Name, 1, 1); oXmlAttributeTreeNode.Nodes.Add( new XmlTextTreeNode(oXmlAttribute.Value, 2, 2)); oXmlElementTreeNode.Nodes.Add(oXmlAttributeTreeNode); } } } if (oXmlNode.ChildNodes.Count == 1 && oXmlNode.FirstChild.NodeType == System.Xml.XmlNodeType.Text) { oXmlElementTreeNode.ForeColor = System.Drawing.Color.DarkKhaki; oXmlElementTreeNode.Nodes.Add(new XmlTextTreeNode(oXmlNode.InnerText, 2, 2)); } else if (oXmlNode.ChildNodes.Count == 0) { oXmlElementTreeNode.ForeColor = System.Drawing.Color.DarkKhaki; } break; case System.Xml.XmlNodeType.Text: // break; } foreach (System.Xml.XmlNode ChildNode in oXmlNode.ChildNodes) { if (ChildNode.NodeType == System.Xml.XmlNodeType.Comment) { oXmlElementTreeNode.Nodes.Add(new XmlCommentTreeNode(ChildNode.Value, 4, 4)); } if (ChildNode.NodeType != System.Xml.XmlNodeType.Text && ChildNode.NodeType != System.Xml.XmlNodeType.Comment) { XmlElementTreeNode El = CreateElement(ChildNode); oXmlElementTreeNode.Nodes.Add(El); } } return(oXmlElementTreeNode); }