//Load TreeView private void displayNavigator(XPathNodeIterator xpi) { if ((xpi != null) && (xpi.Count > 0)) { for (bool hasNext = xpi.MoveNext(); hasNext; hasNext = xpi.MoveNext()) { // IXmlLineInfo lineInfo = xpi.Current as IXmlLineInfo; switch (xpi.Current.NodeType) { case XPathNodeType.Text: { TreeViewItem node = new TreeViewItem(); node.Header = xpi.Current.Value; node.Foreground = Brushes.Brown; node.ToolTip = "(Nodeset/Text)"; tvxpath.Items.Add(node); break; } case XPathNodeType.Attribute: { TreeViewItem node = new TreeViewItem(); node.Header = "@" + xpi.Current.Name + ": " + xpi.Current.Value; node.Foreground = Brushes.Brown; node.ToolTip = "(Nodeset/Attribute)"; node.Tag = xpi.Current.Clone(); tvxpath.Items.Add(node); break; } case XPathNodeType.Element: { var document = new XSDocument(xpi.Current.OuterXml); ViewerNode vNode = new ViewerNode(document); TreeViewItem tvi = TreeViewHelper.BuildTreeView(vNode); tvxpath.Items.Add(tvi); break; } } if (string.IsNullOrEmpty(xmlin.Text)) { xmlin.Text = xpi.Current.OuterXml; } else { xmlin.Text = xmlin.Text + "\r\n" + xpi.Current.OuterXml; } } } else { tvxpath.Items.Add("Nothing found."); xmlin.Text = ""; } }
private ViewerNode(XSDocument doc, XmlNode originalNode, ViewerNode parent, int occurrenceIndex = -1) { _document = doc; // ChildNodes = new List<ViewerNode>(); Attributes = new List <ViewerNode>(); NodeType = NodeType.Unknown; _originalNode = originalNode; _parent = parent; OccurrenceIndex = occurrenceIndex; Build(); }
public ViewerNode(XSDocument doc) : this(doc, doc.XmlDoc.DocumentElement, null) { }