Пример #1
0
        /// <summary>
        /// Gets the name of the attribute and its prefix at the specified index. The index
        /// can be anywhere inside the attribute name or in the attribute value.
        /// The namespace for the element containing the attribute will also be determined
        /// if the includeNamespace flag is set to true.
        /// </summary>
        public static QualifiedName GetQualifiedAttributeNameAtIndex(string xml, int index, bool includeNamespace)
        {
            string        name          = GetAttributeNameAtIndex(xml, index);
            QualifiedName qualifiedName = QualifiedName.FromString(name);

            if (!qualifiedName.IsEmpty && !qualifiedName.HasNamespace && includeNamespace)
            {
                XmlElementPath path = GetActiveElementStartPathAtIndex(xml, index);
                qualifiedName.Namespace = path.GetNamespaceForPrefix(path.Elements.GetLastPrefix());
            }
            return(qualifiedName);
        }
Пример #2
0
        /// <summary>
        /// Gets the element name from the element start tag string.
        /// </summary>
        /// <param name="xml">This string must start at the
        /// element we are interested in.</param>
        static QualifiedName GetElementName(string xml)
        {
            string name = String.Empty;

            // Find the end of the element name.
            xml = xml.Replace("\r\n", " ");
            int index = xml.IndexOf(' ');

            if (index > 0)
            {
                name = xml.Substring(1, index - 1);
            }
            else
            {
                name = xml.Substring(1);
            }

            return(QualifiedName.FromString(name));
        }
Пример #3
0
        /// <summary>
        /// Gets the attribute name and any prefix. The namespace
        /// is not determined.
        /// </summary>
        public static QualifiedName GetQualifiedAttributeName(string xml, int index)
        {
            string name = GetAttributeName(xml, index);

            return(QualifiedName.FromString(name));
        }