Writes out the specified namespace-qualified name by looking up the prefix that is in scope for the given namespace.
[Visual Basic] MustOverride Public Sub WriteQualifiedName( _ ByVal name As String, _ ByVal ns As String _ ) [C#] public abstract void WriteQualifiedName( string name, string ns ); [C++] public: virtual void WriteQualifiedName( String* name, String* ns ) = 0; [JScript] public abstract function WriteQualifiedName( name : String, ns : String );
For example, the following code:
writer.WriteStartElement("root"); writer.WriteAttribute("xmlns:x","urn:abc"); writer.WriteEmptyElement("item"); writer.WriteStartAttribute("href",null); writer.WriteString("#"); writer.WriteQualifiedName("foo","urn:abc"); writer.WriteEndAttribute(); writer.WriteEndElement(); writer.WriteEndElement(); writer.Close();
Will generate the following output:
<root xmlns:x="urn:abc"> <item href="#x:foo"/> </root>
When writing attribute values it will generate a prefix if the specified namespace is not found.If the namespace maps to the current default namespace then it does not need a prefix. When writing element content it will throw an exception if the namespace is not found.
If the Namespace flag is turned on then it will also make sure the name is valid according to the Namespaces in XML specification (
XmlWriter Class | XmlWriter Members | System.NewXml Namespace