private static XmlNodeList SelectAbsoluteNodes(XmlNode rootNode, string path) { var pos = 1; var xmlNode = rootNode; int startPos; while (true) { startPos = pos; var childNodes = xmlNode.ChildNodes; var num = PathDescriptorParser.ReadPosition(path, ref pos); if (pos == path.Length || path[pos] == '/') { if (childNodes.Count == 0 || num < 0 || num > childNodes.Count) { PathDescriptorParser.OnNoMatchingNode(path); } xmlNode = childNodes.Item(num - 1); if (pos != path.Length) { ++pos; } else { break; } } else if (path[pos] != '-' && path[pos] != '|') { PathDescriptorParser.OnInvalidExpression(path); } else { goto label_8; } } var xmlPatchNodeList = (XmlPatchNodeList) new SingleNodeList(); xmlPatchNodeList.AddNode(xmlNode); return((XmlNodeList)xmlPatchNodeList); label_8: return(PathDescriptorParser.SelectChildNodes(xmlNode, path, startPos)); }
private static XmlNodeList SelectChildNodes( XmlNode parentNode, string path, int startPos) { var pos = startPos; var childNodes = parentNode.ChildNodes; var num1 = PathDescriptorParser.ReadPosition(path, ref pos); var xmlPatchNodeList = pos != path.Length ? (XmlPatchNodeList) new MultiNodeList() : (XmlPatchNodeList) new SingleNodeList(); while (true) { if (num1 <= 0 || num1 > childNodes.Count) { PathDescriptorParser.OnNoMatchingNode(path); } var node = childNodes.Item(num1 - 1); xmlPatchNodeList.AddNode(node); if (pos != path.Length) { if (path[pos] == '|') { ++pos; } else if (path[pos] == '-') { ++pos; var num2 = PathDescriptorParser.ReadPosition(path, ref pos); if (num2 <= 0 || num2 > childNodes.Count) { PathDescriptorParser.OnNoMatchingNode(path); } while (num1 < num2) { ++num1; node = node.NextSibling; xmlPatchNodeList.AddNode(node); } if (pos != path.Length) { if (path[pos] == '|') { ++pos; } else { PathDescriptorParser.OnInvalidExpression(path); } } else { break; } } num1 = PathDescriptorParser.ReadPosition(path, ref pos); } else { break; } } return((XmlNodeList)xmlPatchNodeList); }