本文整理汇总了C#中System.Xml.XPath.XPathNavigator.MoveToNext方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.MoveToNext方法的具体用法?C# XPathNavigator.MoveToNext怎么用?C# XPathNavigator.MoveToNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.MoveToNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Traverse
private static void Traverse(TextWriter writer, XPathNavigator nav, int depth = 0)
{
var leadIn = new string(Constants.Tab, depth);
if (nav.NodeType == XPathNodeType.Root)
nav.MoveToFirstChild();
do
{
switch (nav.NodeType)
{
case XPathNodeType.Element:
WriteElement(writer, nav, depth, leadIn);
break;
case XPathNodeType.Text:
WriteTextData(writer, nav, leadIn);
break;
case XPathNodeType.Comment:
WriteComment(writer, nav, leadIn);
break;
default:
throw new InvalidDataException("Encountered unsupported node type of " + nav.NodeType);
}
} while (nav.MoveToNext());
}
示例2: GetStringXML
public static string GetStringXML(XPathNavigator xPathNavigator)
{
if (xPathNavigator.MoveToNext ())
{
return xPathNavigator.Value;
}
return null;
}
示例3: MoveToAddressingHeaderSibling
internal static bool MoveToAddressingHeaderSibling(XPathNavigator nav, string name)
{
while (nav.MoveToNext())
{
if ((nav.LocalName == name) && ((nav.NamespaceURI == "http://www.w3.org/2005/08/addressing") || (nav.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/08/addressing")))
{
return true;
}
}
return false;
}
示例4: EnumerateChildren
public static IEnumerable<XPathNavigator> EnumerateChildren(XPathNavigator navigator)
{
if (navigator.MoveToFirstChild())
{
do
{
yield return navigator;
} while (navigator.MoveToNext());
navigator.MoveToParent();
}
}
示例5: ReadXml
public void ReadXml(XPathNavigator node) {
if (node.MoveToFirstAttribute()) {
do {
if (String.IsNullOrEmpty(node.NamespaceURI)) {
switch (node.LocalName) {
case "method":
switch (node.Value) {
case "xml":
this.Method = XmlSerializationOptions.Methods.Xml;
break;
case "html":
this.Method = XmlSerializationOptions.Methods.Html;
break;
case "xhtml":
this.Method = XmlSerializationOptions.Methods.XHtml;
break;
case "text":
this.Method = XmlSerializationOptions.Methods.Text;
break;
}
break;
default:
break;
}
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
if (node.MoveToFirstChild()) {
do {
if (node.NodeType == XPathNodeType.Element || node.NodeType == XPathNodeType.Text) {
this.Content = node.Clone();
break;
}
} while (node.MoveToNext());
node.MoveToParent();
}
}
示例6: update
/// <summary>
/// Updates all of the <c>Torrent</c> object's properties.
/// </summary>
/// <param name="node">Torrent XML node</param>
public void update(XPathNavigator node)
{
node.MoveToFirstChild();
hash = node.Value;
node.MoveToNext();
status = Convert.ToInt64(node.Value);
node.MoveToNext();
name = node.Value;
node.MoveToNext();
size = Convert.ToInt64(node.Value);
node.MoveToNext();
percent_progress = Convert.ToInt64(node.Value);
// skip a tonne of properties
for (int i = 0; i < 17; i++) node.MoveToNext();
status_message = node.Value;
calculateStatus();
last_modified = DateTime.Now;
// be kind, rewind
node.MoveToParent();
}
示例7: ResourceDataToDictionary
//creates a dictionary of values found in XML
private static Dictionary<string, string> ResourceDataToDictionary(XPathNavigator xPathNavigator)
{
Dictionary<string, string> dict = new Dictionary<string, string>();
if (xPathNavigator.MoveToFirstChild()) //children
{
dict.Add(xPathNavigator.Name, xPathNavigator.Value);
while (xPathNavigator.MoveToNext())
{
dict.Add(xPathNavigator.Name, xPathNavigator.Value);
}
}
xPathNavigator.MoveToParent();
return dict;
}
示例8: DisplayTree
/// <summary>
/// Walks the XPathNavigator tree recursively
/// </summary>
/// <param name="myXPathNavigator"></param>
public static void DisplayTree(XPathNavigator myXPathNavigator)
{
if (myXPathNavigator.HasChildren)
{
myXPathNavigator.MoveToFirstChild();
Format(myXPathNavigator);
DisplayTree(myXPathNavigator);
myXPathNavigator.MoveToParent();
}
while (myXPathNavigator.MoveToNext())
{
Format(myXPathNavigator);
DisplayTree(myXPathNavigator);
}
}
示例9: MoveToAddressingHeader
internal static bool MoveToAddressingHeader(XPathNavigator nav, string name)
{
if (MoveToHeader(nav))
{
if (!nav.MoveToFirstChild())
{
return false;
}
do
{
if ((nav.LocalName == name) && (((nav.NamespaceURI == "http://www.w3.org/2005/08/addressing") || (nav.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/08/addressing")) || (nav.NamespaceURI == "http://schemas.microsoft.com/ws/2005/05/addressing/none")))
{
return true;
}
}
while (nav.MoveToNext());
}
return false;
}
示例10: DavProperty
/// <summary>
/// WebDav Property.
/// </summary>
/// <param name="property"></param>
public DavProperty(XPathNavigator property)
{
if (property == null)
throw new ArgumentNullException("property", InternalFunctions.GetResourceString("ArgumentNullException", "Property"));
else if (property.NodeType != XPathNodeType.Element)
throw new ArgumentException(InternalFunctions.GetResourceString("XPathNavigatorElementArgumentException", "Property"), "property");
base.Name = property.LocalName;
base.Namespace = property.NamespaceURI;
if (property.HasAttributes)
{
//TODO: Support element attributes
//string _here = "";
//Add the attributes first
// foreach (XmlAttribute _xmlAttribute in property.Attributes)
// Attributes.Add(new DavPropertyAttribute(_xmlAttribute));
}
if (property.MoveToFirstChild())
{
if (property.NodeType == XPathNodeType.Element)
{
NestedProperties.Add(new DavProperty(property.Clone()));
while (property.MoveToNext())
{
if (property.NodeType == XPathNodeType.Element)
NestedProperties.Add(new DavProperty(property.Clone()));
}
}
else if (property.NodeType == XPathNodeType.Text)
{
base.Value = property.Value;
property.MoveToParent();
}
}
}
示例11: RecursiveWalkThroughXpath
public void RecursiveWalkThroughXpath(XPathNavigator navigator)
{
switch (navigator.NodeType)
{
case XPathNodeType.Root:
//TODO: do this better ie parse xml or html decelration
if (IncludeDocType)
{
textWriter.Write("!!!");
textWriter.Write(Environment.NewLine);
}
break;
case XPathNodeType.Element:
ProcessElement(navigator);
break;
case XPathNodeType.Text:
ProcessText(navigator);
break;
}
if (navigator.MoveToFirstChild())
{
do
{
RecursiveWalkThroughXpath(navigator);
} while (navigator.MoveToNext());
navigator.MoveToParent();
CheckUnIndent(navigator);
}
else
{
CheckUnIndent(navigator);
}
}
示例12: GetNamespaceConsistentTree
private void GetNamespaceConsistentTree (XPathNavigator nav)
{
nav.MoveToFirstChild ();
nav.MoveToFirstChild ();
nav.MoveToNext ();
Assert.AreEqual ("ns1", nav.GetNamespace (""), "#1." + nav.GetType ());
nav.MoveToNext ();
nav.MoveToNext ();
Assert.AreEqual ("", nav.GetNamespace (""), "#2." + nav.GetType ());
}
示例13: XmlTwoElementsContent
private void XmlTwoElementsContent (XPathNavigator nav)
{
AssertNavigator ("#1", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
Assert.IsTrue (nav.MoveToFirstChild ());
AssertNavigator ("#2", nav, XPathNodeType.Element, "", "foo", "", "foo", "", false, true, false);
Assert.IsTrue (!nav.MoveToNext ());
Assert.IsTrue (!nav.MoveToPrevious ());
Assert.IsTrue (nav.MoveToFirstChild ());
AssertNavigator ("#3", nav, XPathNodeType.Element, "", "bar", "", "bar", "", false, false, true);
Assert.IsTrue (!nav.MoveToFirstChild ());
Assert.IsTrue (nav.MoveToNext ());
AssertNavigator ("#4", nav, XPathNodeType.Element, "", "baz", "", "baz", "", false, false, true);
Assert.IsTrue (!nav.MoveToFirstChild ());
Assert.IsTrue (nav.MoveToPrevious ());
AssertNavigator ("#5", nav, XPathNodeType.Element, "", "bar", "", "bar", "", false, false, true);
nav.MoveToRoot ();
AssertNavigator ("#6", nav, XPathNodeType.Root, "", "", "", "", "", false, true, false);
Assert.IsTrue (!nav.MoveToNext ());
}
示例14: CompareSiblings
private XmlNodeOrder CompareSiblings(XPathNavigator n1, XPathNavigator n2)
{
int num = 0;
switch (n1.NodeType)
{
case XPathNodeType.Attribute:
num++;
break;
case XPathNodeType.Namespace:
break;
default:
num += 2;
break;
}
switch (n2.NodeType)
{
case XPathNodeType.Attribute:
num--;
if (num == 0)
{
while (n1.MoveToNextAttribute())
{
if (n1.IsSamePosition(n2))
{
return XmlNodeOrder.Before;
}
}
}
break;
case XPathNodeType.Namespace:
if (num == 0)
{
while (n1.MoveToNextNamespace())
{
if (n1.IsSamePosition(n2))
{
return XmlNodeOrder.Before;
}
}
}
break;
default:
num -= 2;
if (num == 0)
{
while (n1.MoveToNext())
{
if (n1.IsSamePosition(n2))
{
return XmlNodeOrder.Before;
}
}
}
break;
}
if (num >= 0)
{
return XmlNodeOrder.After;
}
return XmlNodeOrder.Before;
}
示例15: GetNodeInfo
// Begin: GetNodeInfo
private void GetNodeInfo(XPathNavigator nav1)
{
if (nav1 != null && nav1.Name != null && nav1.Name.ToString(CultureInfo.CurrentCulture).Equals("images", StringComparison.CurrentCulture))
{
using (var xmlReader = nav1.ReadSubtree())
{
var searchResults = new SearchResults();
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element)
{
switch (xmlReader.Name)
{
case "id":
searchResults = new SearchResults();
searchResults.Id = xmlReader.ReadString();
continue;
case "album":
searchResults.Album = xmlReader.ReadString();
continue;
case "title":
searchResults.Title = xmlReader.ReadString();
continue;
case "alias":
searchResults.AddAlias(xmlReader.ReadString());
continue;
case "mbid":
searchResults.MBID = xmlReader.ReadString();
continue;
case "votes":
alSearchResults.Add(searchResults);
continue;
default:
continue;
}
}
}
}
}
if (nav1 != null && nav1.HasChildren)
{
nav1.MoveToFirstChild();
while (nav1.MoveToNext())
{
GetNodeInfo(nav1);
nav1.MoveToParent();
}
}
else
{
if (nav1 == null || !nav1.MoveToNext())
return;
GetNodeInfo(nav1);
}
}