private void buttonQuery_Click(object sender, RoutedEventArgs e) { string query = txtQuery.Text; if (query.Length > 0) { TreeViewItem item = (TreeViewItem)treeCtrl.SelectedItem; if (item != null) { ROMNode node = (ROMNode)item.Tag; if (node != null) { try { if (checkQueryValue.IsChecked == true) //rule table input type attr query { ROMNode[] results = node.FindObjects(query); string msg = results.Length.ToString() + " Objects Found"; MessageBox.Show(msg, "XPATH Result", MessageBoxButton.OK); //highlight the objects in the tree foreach (ROMNode nodeRes in results) { item = (TreeViewItem)treeCtrl.FindName("_" + nodeRes.GetROMGUID().Replace('-', '_')); if (item != null) { item.IsSelected = true; item.Foreground = new SolidColorBrush(Colors.Red); object newParent = item.Parent; TreeViewItem parent = null; if (newParent != null && newParent is TreeViewItem) { parent = (TreeViewItem)newParent; } while (parent != null) { parent.IsExpanded = true; newParent = parent.Parent; if (newParent != null && newParent is TreeViewItem) { parent = (TreeViewItem)newParent; } else { parent = null; } } } } } else { string msg = "value: "; msg += node.EvaluateXPATH(query); MessageBox.Show(msg, "XPATH Result", MessageBoxButton.OK); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Query error", MessageBoxButton.OK); } } } } }