当前位置: 首页>>代码示例>>C#>>正文


C# XPathNavigator.MoveToParent方法代码示例

本文整理汇总了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");
			
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:29,代码来源:editing.cs

示例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();
             }
        }
开发者ID:skurdiukov,项目名称:myxsl,代码行数:26,代码来源:XPathMailAddress.cs

示例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();
            }

        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:33,代码来源:ParameterNode.cs

示例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();
             }
        }
开发者ID:richardschneider,项目名称:sepia,代码行数:59,代码来源:XPathHelper.cs

示例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();
            }
             }
        }
开发者ID:skurdiukov,项目名称:myxsl,代码行数:56,代码来源:XPathHttpMultipart.cs

示例6: GetChildNodesValue

 private string GetChildNodesValue(XPathNavigator nav, string nodeName)
 {
     string value = string.Empty;
     if (nav.MoveToChild(nodeName, ""))
     {
         value = nav.Value;
         nav.MoveToParent();
     }
     return value;
 }
开发者ID:purplecow,项目名称:Media-Browser,代码行数:10,代码来源:FilmTrailerFolder.cs

示例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);
     }
 }
开发者ID:neemask,项目名称:meta-core,代码行数:12,代码来源:CyphyMetaLinkUtils.cs

示例8: EnumerateChildren

        public static IEnumerable<XPathNavigator> EnumerateChildren(XPathNavigator navigator)
        {
            if (navigator.MoveToFirstChild())
            {
                do
                {
                    yield return navigator;
                } while (navigator.MoveToNext());

                navigator.MoveToParent();
            }
        }
开发者ID:joaohortencio,项目名称:n2cms,代码行数:12,代码来源:XmlReader.cs

示例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;
 }
开发者ID:joaohortencio,项目名称:n2cms,代码行数:12,代码来源:XmlReader.cs

示例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();
         }
      }
开发者ID:nuxleus,项目名称:Nuxleus,代码行数:50,代码来源:XPathMailBody.cs

示例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();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:XmlDocumentSchema.cs

示例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;
        }
开发者ID:edcombs,项目名称:ResourcesConverter,代码行数:17,代码来源:Load.cs

示例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);
            }
        }
开发者ID:gumpyoung,项目名称:ilabproject-code,代码行数:21,代码来源:XmlQueryDoc.cs

示例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;
        }
开发者ID:peeboo,项目名称:open-media-library,代码行数:18,代码来源:TheMovieDbBackDropDownloader.cs

示例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();
                }
            }
        }
开发者ID:atallo,项目名称:webdavserver,代码行数:42,代码来源:DavProperty.cs


注:本文中的System.Xml.XPath.XPathNavigator.MoveToParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。