private bool popEndElement(XmlReader reader, XmlPath path)
 {
     if (!reader.IsStartElement() && !reader.HasValue)
     {
         path.Pop();
         return true;
     }
     return false;
 }
        private void scanDocumentFor(string projectFile, Action<XmlReader, XmlPath> handler)
        {
            if (!File.Exists(projectFile))
                return;
            using (var reader = XmlReader.Create(projectFile))
            {
                var path = new XmlPath();
                while (reader.Read())
                {
                    if (popEndElement(reader, path))
                        continue;
                    if (reader.Name.Length == 0)
                        continue;
                    path.Push(reader.Name);

                    handler.Invoke(reader, path);

                    if (reader.IsEmptyElement)
                        path.Pop();
                }
            }
        }