Esempio n. 1
0
        public void ParseContains(string containsOfFile)
        {
            string openTagPattern = @"(<.[^(/><.)]+>)";

            while (Regex.IsMatch(containsOfFile, openTagPattern))
            {
                ;
            }
            {
                string foundTag      = Regex.Match(containsOfFile, openTagPattern).ToString();
                string tagName       = GetTagName(foundTag);
                string clozedTagName = GetTagName(tagName);
                int    startOfBody   = containsOfFile.IndexOf(foundTag) + foundTag.Length;
                int    endOfBody     = containsOfFile.IndexOf(clozedTagName) + clozedTagName.Length;
                string body          = containsOfFile.Substring(startOfBody, endOfBody);

                XMLContains contains = new XMLContains(tagName);
                AddAttrIntoElement(foundElement, newXmlElement);
                if (Regex.IsMatch(foundTagBody, openTagPattern))
                {
                    DepthXMLParse(newXmlElement, foundTagBody);
                    xmlString = RemoveParsedBody(bodyStartPoint, bodyEndPoint, foundElement, tagName, xmlString);
                }
                else
                {
                    newXmlElement.SetBody(foundTagBody);
                    xmlString = RemoveParsedBody(bodyStartPoint, bodyEndPoint, foundElement, tagName, xmlString);
                }
                headElement.AddNested(newXmlElement);

                /*if(Regex.IsMatch(body, openTagPattern))
                 * {
                 * ParseContains(body);
                 *
                 * }
                 * else
                 * {
                 *
                 * }*/
            }
        }
Esempio n. 2
0
        /* private void AddAttributes(StringBuilder nameHierarchy)
         * {
         * if (tagAttributes.Count != 0)
         * {
         *   nameHierarchy.Append("{ ");
         *   foreach (DictionaryEntry attr in tagAttributes)
         *   {
         *     nameHierarchy.Append($"{attr.Key} = {attr.Value}; ");
         *   }
         *   nameHierarchy.Append("} -> ");
         * }
         * }*/

        /* /// <summary>
         * /// Adds another attribute to this instance's
         * /// tagAttributes Hashtable
         * /// </summary>
         * /// <param name="attrName">
         * /// Key of new attribute
         * /// </param>
         * /// <param name="attrValue">
         * /// Value of new attribute
         * /// </param>
         * public void AddAttr(string attrName, string attrValue)
         * {
         * tagAttributes.Add(attrName.Trim(), attrValue.Trim());
         * }*/

        /// <summary>
        /// Add another nested element to this instance's
        /// nestedElements list
        /// </summary>
        /// <param name="newNestedElement">
        /// XMLElement to add
        /// </param>
        public void AddNested(XMLContains newNestedElement)
        {
            nestedElements.Add(newNestedElement);
        }
Esempio n. 3
0
 /// <summary>
 /// Comparer implimented from IComparer
 /// </summary>
 /// <param name="other">
 /// XMLElement to campare with
 /// </param>
 /// <returns>
 /// Return result of comparasing 2 XMLElement's instances
 /// </returns>
 public int CompareTo(XMLContains other)
 {
     return(tagName.CompareTo(other.tagName));
 }