System.Xml.XPath.XPathNavigator.MoveToPrevious C# (CSharp) Method

MoveToPrevious() private method

private MoveToPrevious ( string localName, string namespaceURI ) : bool
localName string
namespaceURI string
return bool
        internal bool MoveToPrevious(string localName, string namespaceURI)
        {
            XPathNavigator navClone = Clone();

            localName = (localName != null) ? NameTable.Get(localName) : null;
            while (MoveToPrevious())
            {
                if (NodeType == XPathNodeType.Element && (object)localName == (object)LocalName && namespaceURI == NamespaceURI)
                    return true;
            }

            MoveTo(navClone);
            return false;
        }

Same methods

XPathNavigator::MoveToPrevious ( ) : bool
XPathNavigator::MoveToPrevious ( XPathNodeType type ) : bool

Usage Example

Exemplo n.º 1
0
		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");
			
		}
All Usage Examples Of System.Xml.XPath.XPathNavigator::MoveToPrevious