本文整理汇总了C#中System.Xml.XPath.XPathNavigator.SelectDescendants方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.SelectDescendants方法的具体用法?C# XPathNavigator.SelectDescendants怎么用?C# XPathNavigator.SelectDescendants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.SelectDescendants方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItems
private IWriter[] GetItems(XPathNavigator node)
{
var dlvs = node.SelectDescendants("DLV", node.NamespaceURI, true);
var mappedDlvs = _dlvReader.Read(dlvs);
return mappedDlvs.ToArray();
}
示例2: LoadBook
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);
}
示例3: BuildKeyTable
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;
}
示例4: advance
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;
}
示例5: FixCodeNodes
/* 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);
}
示例6: GetDescendants
/// <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);
}
示例7: FindChildElement
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
}
示例8: GetTaskDifficultyTag
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;
}