private static XDoc AtXPathNode(XDoc doc, string xpath, Hashtable namespaces)
        {
            XDoc result = doc;

            // check if xpath selects anything other than the current node
            if (!string.IsNullOrEmpty(xpath) && !xpath.EqualsInvariant("."))
            {
                // check if custom namespace mapping was provided
                if (namespaces != null)
                {
                    // initialize a namespace manager
                    XmlNamespaceManager nsm = new XmlNamespaceManager(SysUtil.NameTable);
                    foreach (DictionaryEntry ns in namespaces)
                    {
                        nsm.AddNamespace((string)ns.Key, SysUtil.ChangeType <string>(ns.Value));
                    }
                    result = doc.AtPath(xpath, nsm);
                }
                else
                {
                    // use default namespace manager
                    result = doc[xpath];
                }
            }
            return(result);
        }
        private ArrayList AtXPathList(XDoc doc, string xpath, Hashtable namespaces, bool asXml)
        {
            XDoc node;

            if (namespaces != null)
            {
                // initialize a namespace manager
                XmlNamespaceManager nsm = new XmlNamespaceManager(SysUtil.NameTable);
                foreach (DictionaryEntry ns in namespaces)
                {
                    nsm.AddNamespace((string)ns.Key, SysUtil.ChangeType <string>(ns.Value));
                }
                node = doc.AtPath(xpath, nsm);
            }
            else
            {
                // use default namespace manager
                node = doc[xpath];
            }

            // iterate over all matches
            ArrayList result = new ArrayList();

            foreach (XDoc item in node)
            {
                if (asXml)
                {
                    if (item.AsXmlNode.NodeType == XmlNodeType.Attribute)
                    {
                        result.Add(((XmlAttribute)item.AsXmlNode).OwnerElement.OuterXml);
                    }
                    else
                    {
                        result.Add(item.AsXmlNode.OuterXml);
                    }
                }
                else
                {
                    result.Add(item.AsText);
                }
            }
            return(result);
        }
        private XDoc AtXPathNode(XDoc doc, string xpath, Hashtable namespaces)
        {
            XDoc result = doc;

            if (namespaces != null)
            {
                // initialize a namespace manager
                XmlNamespaceManager nsm = new XmlNamespaceManager(SysUtil.NameTable);
                foreach (DictionaryEntry ns in namespaces)
                {
                    nsm.AddNamespace((string)ns.Key, SysUtil.ChangeType <string>(ns.Value));
                }
                result = doc.AtPath(xpath, nsm);
            }
            else if (!StringUtil.EqualsInvariant(xpath, "."))
            {
                // use default namespace manager
                result = doc[xpath];
            }
            return(result);
        }
        private ArrayList AtXPathList(XDoc doc, string xpath, Hashtable namespaces, bool asXml) {
            XDoc node;
            if(namespaces != null) {

                // initialize a namespace manager
                XmlNamespaceManager nsm = new XmlNamespaceManager(SysUtil.NameTable);
                foreach(DictionaryEntry ns in namespaces) {
                    nsm.AddNamespace((string)ns.Key, SysUtil.ChangeType<string>(ns.Value));
                }
                node = doc.AtPath(xpath, nsm);
            } else {

                // use default namespace manager
                node = doc[xpath];
            }

            // iterate over all matches
            ArrayList result = new ArrayList();
            foreach(XDoc item in node) {
                if(asXml) {
                    if(item.AsXmlNode.NodeType == XmlNodeType.Attribute) {
                        result.Add(((XmlAttribute)item.AsXmlNode).OwnerElement.OuterXml);
                    } else {
                        result.Add(item.AsXmlNode.OuterXml);
                    }
                } else {
                    result.Add(item.AsText);
                }
            }
            return result;
        }
        private XDoc AtXPathNode(XDoc doc, string xpath, Hashtable namespaces) {
            XDoc result = doc;
            if(namespaces != null) {

                // initialize a namespace manager
                XmlNamespaceManager nsm = new XmlNamespaceManager(SysUtil.NameTable);
                foreach(DictionaryEntry ns in namespaces) {
                    nsm.AddNamespace((string)ns.Key, SysUtil.ChangeType<string>(ns.Value));
                }
                result = doc.AtPath(xpath, nsm);
            } else if(!StringUtil.EqualsInvariant(xpath, ".")) {

                // use default namespace manager
                result = doc[xpath];
            }
            return result;
        }
        private static XDoc AtXPathNode(XDoc doc, string xpath, Hashtable namespaces) {
            XDoc result = doc;

            // check if xpath selects anything other than the current node
            if(!string.IsNullOrEmpty(xpath) && !xpath.EqualsInvariant(".")) {

                // check if custom namespace mapping was provided
                if(namespaces != null) {

                    // initialize a namespace manager
                    XmlNamespaceManager nsm = new XmlNamespaceManager(SysUtil.NameTable);
                    foreach(DictionaryEntry ns in namespaces) {
                        nsm.AddNamespace((string)ns.Key, SysUtil.ChangeType<string>(ns.Value));
                    }
                    result = doc.AtPath(xpath, nsm);
                } else {

                    // use default namespace manager
                    result = doc[xpath];
                }
            }
            return result;
        }