/// <summary>
        /// Parses the provided document into discrete components using the regex provided and
        /// provides the information to the provided reader, see XmlLightDocument
        /// </summary>
        public static void Parse(string content, Regex parserExp, IXmlLightReader reader)
        {
            XmlTagInfo tagInfo;

            int pos = 0;

            reader.StartDocument();

            foreach (Match element in parserExp.Matches(content))
            {
                Group tag = element.Groups["tag"];

                if (pos < element.Index)
                {
                    reader.AddText(content.Substring(pos, element.Index - pos));
                }
                pos = element.Index + element.Length;

                if (tag.Success)
                {
                    tagInfo.UnparsedTag      = element.Value;
                    tagInfo.FullName         = tag.Value;
                    tagInfo.SelfClosed       = element.Groups["closed"].Success;
                    tagInfo.EndingWhitespace = element.Groups["wsattrend"].Value;


                    if (element.Groups["close"].Success)
                    {
                        tagInfo.Attributes = XmlLightAttribute.EmptyList;
                        reader.EndTag(tagInfo);
                    }
                    else
                    {
                        tagInfo.Attributes = AttributeReader(element);
                        reader.StartTag(tagInfo);
                    }
                }
                else
                {
                    Group comment = element.Groups["comment"];
                    if (comment.Success)
                    {
                        reader.AddComment(element.Value);
                    }
                    else
                    {
                        Group cdata = element.Groups["cdata"];
                        if (cdata.Success)
                        {
                            reader.AddCData(element.Value);
                        }
                        else
                        {
                            Group special = element.Groups["special"];
                            if (special.Success)
                            {
                                reader.AddControl(element.Value);
                            }
                            else
                            {
                                Group instruction = element.Groups["instruction"];
                                if (instruction.Success)
                                {
                                    reader.AddInstruction(element.Value);
                                }
                            }
                        }
                    }
                }
            }

            if (pos < content.Length)
            {
                reader.AddText(content.Substring(pos, content.Length - pos));
            }

            reader.EndDocument();
        }
 /// <summary>
 /// Parses the provided xml/html document into discrete components and provides the
 /// information to the provided reader, see XmlLightDocument
 /// </summary>
 public static void Parse(string content, AttributeFormat format, IXmlLightReader reader)
 {
     Parse(content, format == AttributeFormat.Html ? HtmlElementParsing : XmlElementParsing, reader);
 }
 /// <summary>
 /// Parses the provided xml/html document into discrete components and provides the
 /// information to the provided reader, see XmlLightDocument
 /// </summary>
 public static void Parse(string content, IXmlLightReader reader)
 {
     Parse(content, HtmlElementParsing, reader);
 }
        /// <summary>
        /// Parses the provided document into discrete components using the regex provided and 
        /// provides the information to the provided reader, see XmlLightDocument
        /// </summary>
        public static void Parse(string content, Regex parserExp, IXmlLightReader reader)
        {
        	XmlTagInfo tagInfo;

            int pos = 0;
			reader.StartDocument();

            foreach (Match element in parserExp.Matches(content))
			{
				Group tag = element.Groups["tag"];

				if (pos < element.Index)
					reader.AddText(content.Substring(pos, element.Index - pos));
				pos = element.Index + element.Length;

				if (tag.Success)
				{
					tagInfo.UnparsedTag = element.Value;
					tagInfo.FullName = tag.Value;
					tagInfo.SelfClosed = element.Groups["closed"].Success;
					tagInfo.EndingWhitespace = element.Groups["wsattrend"].Value;
					

					if (element.Groups["close"].Success)
					{
						tagInfo.Attributes = XmlLightAttribute.EmptyList;
						reader.EndTag(tagInfo);
					}
					else
					{
						tagInfo.Attributes = AttributeReader(element);
						reader.StartTag(tagInfo);
					}
				}
				else
				{
					Group comment = element.Groups["comment"];
					if (comment.Success)
						reader.AddComment(element.Value);
					else
					{
						Group cdata = element.Groups["cdata"];
						if (cdata.Success)
							reader.AddCData(element.Value);
						else
						{
							Group special = element.Groups["special"];
							if (special.Success)
								reader.AddControl(element.Value);
							else
							{
								Group instruction = element.Groups["instruction"];
								if (instruction.Success)
									reader.AddInstruction(element.Value);
							}
						}
					}
				}
			}

			if (pos < content.Length)
				reader.AddText(content.Substring(pos, content.Length - pos));

			reader.EndDocument();
		}
 /// <summary>
 /// Parses the provided xml/html document into discrete components and provides the
 /// information to the provided reader, see XmlLightDocument
 /// </summary>
 public static void Parse(string content, AttributeFormat format, IXmlLightReader reader)
 {
     Parse(content, format == AttributeFormat.Html ? HtmlElementParsing : XmlElementParsing, reader);
 }
 /// <summary>
 /// Parses the provided xml/html document into discrete components and provides the
 /// information to the provided reader, see XmlLightDocument
 /// </summary>
 public static void Parse(string content, IXmlLightReader reader)
 {
     Parse(content, HtmlElementParsing, reader);
 }