public static int GetInScopeNamespaces(XPathNode[] pageElem, int idxElem, out XPathNode[] pageNmsp)
 {
     if (pageElem[idxElem].NodeType == XPathNodeType.Element)
     {
         XPathDocument document = pageElem[idxElem].Document;
         while (!pageElem[idxElem].HasNamespaceDecls)
         {
             idxElem = pageElem[idxElem].GetParent(out pageElem);
             if (idxElem == 0)
             {
                 return(document.GetXmlNamespaceNode(out pageNmsp));
             }
         }
         return(document.LookupNamespaces(pageElem, idxElem, out pageNmsp));
     }
     pageNmsp = null;
     return(0);
 }