本文整理汇总了C#中System.Xml.XPath.XPathNavigator.MoveToParent方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.MoveToParent方法的具体用法?C# XPathNavigator.MoveToParent怎么用?C# XPathNavigator.MoveToParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.MoveToParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetXPath
public static string GetXPath (XPathNavigator n)
{
switch (n.NodeType) {
case XPathNodeType.Root: return "/";
case XPathNodeType.Attribute: {
string ret = "@" + n.Name;
n.MoveToParent ();
string s = GetXPath (n);
return s + (s == "/" ? "" : "/") + ret;
}
case XPathNodeType.Element: {
string ret = n.Name;
int i = 1;
while (n.MoveToPrevious ()) {
if (n.NodeType == XPathNodeType.Element && n.Name == ret)
i++;
}
ret += "[" + i + "]";
if (n.MoveToParent ()) {
string s = GetXPath (n);
return s + (s == "/" ? "" : "/") + ret;
}
}
break;
}
throw new Exception ("node type not supported for editing");
}
示例2: ReadXml
public void ReadXml(XPathNavigator node)
{
if (node.MoveToFirstAttribute()) {
do {
if (String.IsNullOrEmpty(node.NamespaceURI)) {
switch (node.LocalName) {
case "address":
this.Address = node.Value;
break;
case "display-name":
this.DisplayName = node.Value;
break;
default:
break;
}
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
}
示例3: ParameterNode
public ParameterNode(XPathNavigator aNode)
{
valueNode = String.Empty;
typeNode = String.Empty;
ruleValueNode = String.Empty;
name = String.Empty;
if (aNode.MoveToFirstAttribute())
{
do
{
string nodeName = aNode.Name;
switch (nodeName)
{
case PARAMETER_ATTRS.NAME:
name = aNode.Value;
break;
case PARAMETER_ATTRS.VALUE:
valueNode = aNode.Value;
break;
case PARAMETER_ATTRS.TYPE:
typeNode = aNode.Value;
break;
case PARAMETER_ATTRS.RULE_VALUE:
ruleValueNode = aNode.Value;
break;
}
} while (aNode.MoveToNextAttribute());
aNode.MoveToParent();
}
}
示例4: FullName
static void FullName(XPathNavigator navigator, StringBuilder s)
{
if (navigator.NodeType == XPathNodeType.Root)
return;
string name = navigator.Name;
string value = null;
XPathNodeType nodeType = navigator.NodeType;
if (nodeType == XPathNodeType.Attribute)
value = navigator.Value;
int same = 0;
int position = 0;
XPathNavigator sibling = navigator.Clone();
sibling.MoveToFirst();
do
{
if (sibling.NodeType == nodeType && sibling.Name == name)
{
if (sibling.IsSamePosition(navigator))
position = same;
else
++same;
}
} while (sibling.MoveToNext());
if (navigator.MoveToParent())
FullName(navigator, s);
switch (nodeType)
{
case XPathNodeType.Element:
s.Append('/');
s.Append(name);
if (same != 0)
{
s.Append('[');
s.Append((position + 1).ToString(CultureInfo.InvariantCulture));
s.Append(']');
}
break;
case XPathNodeType.Attribute:
s.Append("[@");
s.Append(name);
if (same != 0)
s.AppendFormat(" = '{0}'", value);
s.Append("]");
break;
case XPathNodeType.Comment:
case XPathNodeType.Namespace:
case XPathNodeType.ProcessingInstruction:
case XPathNodeType.Root:
case XPathNodeType.Text:
case XPathNodeType.Whitespace:
default:
throw new NotSupportedException();
}
}
示例5: ReadXml
public void ReadXml(XPathNavigator node, XmlResolver resolver)
{
if (node.NodeType == XPathNodeType.Element) {
if (node.MoveToFirstAttribute()) {
do {
switch (node.LocalName) {
case "media-type":
this.MediaType = node.Value;
break;
case "boundary":
this.Boundary = node.Value;
break;
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
if (node.MoveToChild(XPathNodeType.Element)) {
XPathHttpMultipartItem currentItem = null;
do {
if (node.NamespaceURI == XPathHttpClient.Namespace) {
switch (node.LocalName) {
case "header":
if (currentItem == null) {
currentItem = new XPathHttpMultipartItem();
}
currentItem.Headers.Add(node.GetAttribute("name", ""), node.GetAttribute("value", ""));
break;
case "body":
if (currentItem == null) {
currentItem = new XPathHttpMultipartItem();
}
currentItem.Body = new XPathHttpBody();
currentItem.Body.ReadXml(node, resolver);
this.Items.Add(currentItem);
currentItem = null;
break;
}
}
} while (node.MoveToNext(XPathNodeType.Element));
node.MoveToParent();
}
}
}
示例6: GetChildNodesValue
private string GetChildNodesValue(XPathNavigator nav, string nodeName)
{
string value = string.Empty;
if (nav.MoveToChild(nodeName, ""))
{
value = nav.Value;
nav.MoveToParent();
}
return value;
}
示例7: SetOrCreateXmlAttribute
public static void SetOrCreateXmlAttribute(XPathNavigator node, string localName, string namespaceURI, string value)
{
if (node.MoveToAttribute(localName, namespaceURI))
{
node.SetValue(value);
node.MoveToParent();
}
else
{
node.CreateAttribute("", localName, namespaceURI, value);
}
}
示例8: EnumerateChildren
public static IEnumerable<XPathNavigator> EnumerateChildren(XPathNavigator navigator)
{
if (navigator.MoveToFirstChild())
{
do
{
yield return navigator;
} while (navigator.MoveToNext());
navigator.MoveToParent();
}
}
示例9: GetAttributes
public static Dictionary<string, string> GetAttributes(XPathNavigator navigator)
{
if (!navigator.MoveToFirstAttribute())
throw new DeserializationException("Node has no attributes: " + navigator.Name);
Dictionary<string, string> attributes = new Dictionary<string, string>();
do
{
attributes.Add(navigator.Name, navigator.Value);
} while (navigator.MoveToNextAttribute());
navigator.MoveToParent();
return attributes;
}
示例10: 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();
}
}
示例11: AddAttributeList
private void AddAttributeList(XPathNavigator nav, ArrayList attrs)
{
if (nav.HasAttributes)
{
nav.MoveToFirstAttribute();
do
{
if (!attrs.Contains(nav.Name))
{
attrs.Add(nav.Name);
}
}
while (nav.MoveToNextAttribute());
nav.MoveToParent();
}
}
示例12: 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;
}
示例13: 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);
}
}
示例14: GrabBackDropUrls
public IList<string> GrabBackDropUrls(XPathNavigator nav)
{
List<string> urls = new List<string>();
XPathNodeIterator nIter = nav.SelectChildren("backdrop", "");
if (nav.MoveToFollowing("backdrop", ""))
{
XPathNavigator localNav = nav.CreateNavigator();
nav.MoveToParent();
for (int i = 0; i < nIter.Count; i++)
{
if (localNav.GetAttribute("size", "").ToUpperInvariant().Equals("original".ToUpperInvariant()))
urls.Add(localNav.Value);
localNav.MoveToNext();
}
}
return urls;
}
示例15: 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();
}
}
}