//TODO: respect namespaces
		public void Populate (XDocument doc)
		{
			foreach (XNode node in doc.AllDescendentNodes) {
				XElement el = node as XElement;
				if (el == null)
					continue;
				string parentName = "";
				XElement parentEl = el.Parent as XElement;
				if (parentEl != null)
					parentName = parentEl.Name.Name;
				
				HashSet<string> map;
				if (!elementCompletions.TryGetValue (parentName, out map)) {
					map = new HashSet<string> ();
					elementCompletions.Add (parentName, map);
				}
				map.Add (el.Name.Name);
				
				if (!attributeCompletions.TryGetValue (el.Name.Name, out map)) {
					map = new HashSet<string> ();
					attributeCompletions.Add (el.Name.Name, map);
				}
				foreach (XAttribute att in el.Attributes)
					map.Add (att.Name.Name);
			}
		}
		public WebFormsMemberListBuilder (WebFormsTypeContext refMan, XDocument xDoc)
		{
			docRefMan = refMan;
			xDocument = xDoc;
			
			Errors = new List<Error> ();
			Members = new Dictionary<string,CodeBehindMember> ();
		}
		// Constructor used for testing the XDOM
		public WebFormsParsedDocument (string fileName, WebSubtype type, WebFormsPageInfo info, XDocument xDoc) : 
			base (fileName)
		{
			Flags |= ParsedDocumentFlags.NonSerializable;
			Info = info;
			Type = type;
			XDocument = xDoc;
		}
		IEnumerable<Error> Validate (XDocument doc)
		{
			foreach (XNode node in doc.Nodes) {
				if (node is XElement && !Object.ReferenceEquals (node, doc.RootElement)) {
					yield return new Error (ErrorType.Warning, "More than one root element", node.Region);
				}
			}
		}
		public void Populate (XDocument xDoc, List<Error> errors)
		{
			foreach (XNode node in xDoc.AllDescendentNodes) {
				if (node is WebFormsDirective) {
					HandleDirective (node as WebFormsDirective, errors);
				} else if (node is XDocType) {
					HandleDocType (node as XDocType);
				} else if (node is XElement) {
					// quit the parsing when reached the html nodes
					return;
				}
			}
		}
		void Populate (XDocument doc)
		{
			var project = doc.Nodes.OfType<XElement> ().FirstOrDefault (x => x.Name == xnProject);
			if (project == null)
				return;
			var pel = MSBuildElement.Get ("Project");
			foreach (var el in project.Nodes.OfType<XElement> ())
				Populate (el, pel);
		}