public SelectDescendants ( XPathNodeType type, bool matchSelf ) : |
||
type | XPathNodeType | |
matchSelf | bool | |
return |
private IWriter[] GetItems(XPathNavigator node) { var dlvs = node.SelectDescendants("DLV", node.NamespaceURI, true); var mappedDlvs = _dlvReader.Read(dlvs); return mappedDlvs.ToArray(); }
internal override XPathNavigator advance() { if (proceed) { if (temp == null) { XPathNavigator _eLast = m_qyInput.advance(); while (_eLast != null) { temp = _eLast.Clone(); _eLast = m_qyInput.advance(); } if (temp == null || temp.NodeType == XPathNodeType.Root) { return(null); } if (temp.NodeType == XPathNodeType.Attribute || temp.NodeType == XPathNodeType.Namespace) { temp.MoveToParent(); } NotVisited(temp.Clone()); _AncestorStk.Add(temp.Clone()); temp.MoveToRoot(); _qy = temp.SelectDescendants(XPathNodeType.All, false); } int flag; while (_qy.MoveNext()) { m_eNext = _qy.Current; if (matches(m_eNext)) { flag = InStk(m_eNext); if (flag == 1) { _position++; return(m_eNext); } if (flag == 2) { proceed = false; m_eNext = null; return(null); } } else { if (m_eNext.IsSamePosition((XPathNavigator)_AncestorStk[_AncestorStk.Count - 1])) { proceed = false; m_eNext = null; return(null); } } } return(null); } return(null); }
internal override XPathNavigator advance() { if (_eLast == null) { XPathNavigator temp = null; _eLast = m_qyInput.advance(); if (_eLast == null) { return(null); } while (_eLast != null) { _eLast = _eLast.Clone(); temp = _eLast; _eLast = m_qyInput.advance(); if (!temp.IsDescendant(_eLast)) { break; } } _eLast = temp; } while (true) { if (_first) { _first = false; if (_eLast.NodeType == XPathNodeType.Attribute || _eLast.NodeType == XPathNodeType.Namespace) { _eLast.MoveToParent(); if (_fMatchName) { _qy = _eLast.SelectDescendants(m_Name, m_URN, false); } else { _qy = _eLast.SelectDescendants(m_Type, false); } } else { while (true) { if (!_eLast.MoveToNext()) { if (!_eLast.MoveToParent()) { _first = true; return(null); } } else { break; } } if (_fMatchName) { _qy = _eLast.SelectDescendants(m_Name, m_URN, true); } else { _qy = _eLast.SelectDescendants(m_Type, true); } } } if (_qy.MoveNext()) { _position++; m_eNext = _qy.Current; return(m_eNext); } else { _first = true; } } }
private void LoadBook(XPathNavigator lstNav) { //We are passsed an XPathNavigator of a particular book node //we will select all of the direct descendents and //load the list box with the names and values XPathNodeIterator iterBook=lstNav.SelectDescendants(XPathNodeType.Element,false); while(iterBook.MoveNext()) listBox1.Items.Add(iterBook.Current.Name + ": " + iterBook.Current.Value); }
private Hashtable BuildKeyTable(Key key, XPathNavigator root) { Hashtable keyTable = new Hashtable(); string matchStr = this.processor.GetQueryExpression(key.MatchKey); Query matchExpr = this.processor.GetCompiledQuery(key.MatchKey); Query useExpr = this.processor.GetCompiledQuery(key.UseKey); XPathNodeIterator sel = root.SelectDescendants(XPathNodeType.All, /*matchSelf:*/ false); while(sel.MoveNext()) { XPathNavigator node = sel.Current; EvaluateKey(node, matchExpr, matchStr, useExpr, keyTable); if (node.MoveToFirstAttribute()) { do { EvaluateKey(node, matchExpr, matchStr, useExpr, keyTable); } while (node.MoveToNextAttribute()); node.MoveToParent(); } } return keyTable; }
internal override XPathNavigator advance() { if (proceed) { if (temp == null ) { XPathNavigator _eLast = m_qyInput.advance(); while (_eLast != null){ temp = _eLast.Clone(); _eLast = m_qyInput.advance(); } if (temp == null || temp.NodeType == XPathNodeType.Root) return null; if (temp.NodeType == XPathNodeType.Attribute || temp.NodeType == XPathNodeType.Namespace){ temp.MoveToParent(); } NotVisited(temp.Clone()); _AncestorStk.Add(temp.Clone()); temp.MoveToRoot(); _qy = temp.SelectDescendants(XPathNodeType.All, false); } int flag; while ( _qy.MoveNext()) { m_eNext = _qy.Current; if (matches(m_eNext)){ flag = InStk(m_eNext); if (flag == 1){ _position++; return m_eNext; } if (flag == 2) { proceed = false; m_eNext = null; return null; } } else{ if (m_eNext.IsSamePosition((XPathNavigator)_AncestorStk[_AncestorStk.Count -1])) { proceed = false; m_eNext = null; return null; } } } return null; } return null; }
/* doesn't work because can't modify node via XPathNavigator /// <summary> /// Fix code nodes such that it will be rendered correctly (using pre). /// </summary> /// <param name="topNode"></param> private void FixCodeNodes(XPathNavigator nav) { XPathNodeIterator iter = nav.SelectDescendants("code", string.Empty, true); while(iter.MoveNext()) { XPathNavigator n = iter.Current; n.Value = "<pre class=\"code\">" + n.Value + "</pre>"; } } */ /// <summary> /// Return a new XPathNavigator pointing to the first descendant node /// with the specified name. /// </summary> /// <param name="nodeName">The node name string.</param> /// <param name="startNavigator">Initial node to start search from.</param> /// <returns>An XPathNavigator pointing to the specified descendant, or null /// for not found.</returns> XPathNavigator GetDescendantNodeWithName(XPathNavigator startNavigator, string nodeName) { XPathNodeIterator xni = startNavigator.SelectDescendants(nodeName, "", false); xni.MoveNext(); if (xni.Current.ComparePosition(startNavigator) == XmlNodeOrder.Same) return(null); else return(xni.Current); }
/// <summary> /// Get the descendants of the current node which have the specified /// localName. This just provides a different iteration style /// from XPathNavigator.SelectDescendants(). /// </summary> /// <param name="localName">The localname to select.</param> /// <param name="nav">The XPathNavigator.</param> /// <returns>A new ArrayList of XPathNavigators.</returns> ArrayList GetDescendants(XPathNavigator nav, string localName) { ArrayList list = new ArrayList(); XPathNodeIterator iter = nav.SelectDescendants(localName, "", false); while(iter.MoveNext()) { list.Add(iter.Current.Clone()); } return(list); }
private XPathNavigator FindChildElement(XPathNavigator navigator, IDictionary searchKeys) { XPathNodeIterator nodes = navigator.SelectDescendants(XPathNodeType.Element, false); foreach (XPathNavigator node in nodes) { if (node.HasAttributes == false) continue; // skip empty ones Hashtable attributes = new Hashtable(); // attribute list XPathNavigator attrNavigator = node.Clone(); bool flagMoreAttributes = attrNavigator.MoveToFirstAttribute(); while (flagMoreAttributes) { attributes.Add(attrNavigator.Name, attrNavigator.Value); flagMoreAttributes = attrNavigator.MoveToNextAttribute(); } bool foundit = true; foreach (Object searchKeyObj in searchKeys) { DictionaryEntry searchEntry = (DictionaryEntry)searchKeyObj; string searchKey = searchEntry.Key.ToString(); string searchValue = searchEntry.Value.ToString(); // Match search keys against the child's attributes if (attributes.ContainsKey(searchKey) && attributes[searchKey].ToString() == searchValue) continue; // so far so good. matching so far foundit = false; // no match break; } if (foundit) return node; // return the navigator to found child } // foreach through the element children, still looking return null; // child element not found using the keys }
public int GetTaskDifficultyTag(XPathNavigator rtmCompletedTasksIterator) { // Purpose: Return 0, 1, or 2, equal to the task's difficulty tag "d1" "d2" or "d3". If the task has no "d#" tag, default to "d1". int DifficultyLevel = 0; XPathNodeIterator TagIterator = rtmCompletedTasksIterator.SelectDescendants("tag", "", false); while (TagIterator.MoveNext()) // Search through any <Tag> elements. If multiple "d#" tags are present, return the highest value. { switch (TagIterator.Current.Value.ToString()) { case "d2": { if (DifficultyLevel == 0) { DifficultyLevel = 1; } break; } case "d3": { DifficultyLevel = 2; break; } } } return DifficultyLevel; }