public void CreateQualifiedNameFromStringContainingPrefix()
        {
            QualifiedName name = QualifiedName.FromString("a:root");
            QualifiedName expectedQualifiedName = new QualifiedName("root", String.Empty, "a");

            Assert.AreEqual(expectedQualifiedName, name);
        }
        public void CreateQualifiedNameFromString()
        {
            QualifiedName name = QualifiedName.FromString("root");
            QualifiedName expectedQualifiedName = new QualifiedName("root", String.Empty);

            Assert.AreEqual(expectedQualifiedName, name);
        }
        /// <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);
        }
        /// <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", " ");
            xml = xml.Replace("\n", " ");
            int index = xml.IndexOf(' ');

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

            return(QualifiedName.FromString(name));
        }
        public void CreateQualifiedNameFromNullString()
        {
            QualifiedName name = QualifiedName.FromString(null);

            Assert.IsTrue(name.IsEmpty);
        }
        /// <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));
        }