/* Function: GetAllTagProperties * If <Type> is <XMLElementType.Tag>, this generates a dictionary of all the properties in the tag, if any. */ public Dictionary <string, string> GetAllTagProperties() { if (type != XMLElementType.Tag) { throw new InvalidOperationException(); } Dictionary <string, string> properties = new Dictionary <string, string>(); Match match = TagRegex.Match(RawText, RawTextIndex, length); CaptureCollection captures = match.Groups[2].Captures; foreach (Capture capture in captures) { Match propertyMatch = TagPropertyRegex.Match(RawText, capture.Index, capture.Length); properties.Add(propertyMatch.Groups[1].ToString(), DecodePropertyValue(propertyMatch.Groups[2].Index, propertyMatch.Groups[2].Length)); } return(properties); }
/* Function: TagProperty * If <Type> is <XMLElementType.Tag>, return the value of the passed property, or null if it doesn't exist. The property * name is case-insensitive. */ public string TagProperty(string name) { if (type != XMLElementType.Tag) { throw new InvalidOperationException(); } Match match = TagRegex.Match(RawText, RawTextIndex, length); CaptureCollection captures = match.Groups[2].Captures; foreach (Capture capture in captures) { Match propertyMatch = TagPropertyRegex.Match(RawText, capture.Index, capture.Length); if (name.Length == propertyMatch.Groups[1].Length && string.Compare(name, 0, RawText, propertyMatch.Groups[1].Index, name.Length, true) == 0) { return(DecodePropertyValue(propertyMatch.Groups[2].Index, propertyMatch.Groups[2].Length)); } } return(null); }