Export (0) Print
Expand All

XmlWriter.WriteQualifiedName Method

When overridden in a derived class, writes out the namespace-qualified name. This method looks up the prefix that is in scope for the given namespace.

[Visual Basic]
Public MustOverride Sub WriteQualifiedName( _
   ByVal localName As String, _
   ByVal ns As String _
)
[C#]
public abstract void WriteQualifiedName(
 string localName,
 string ns
);
[C++]
public: virtual void WriteQualifiedName(
 String* localName,
 String* ns
) = 0;
[JScript]
public abstract function WriteQualifiedName(
   localName : String,
 ns : String
);

Parameters

localName
The local name to write.
ns
The namespace URI for the name.

Exceptions

Exception Type Condition
ArgumentException localName is either a null reference (Nothing in Visual Basic) or String.Empty.

localName is not a valid name.

Remarks

For example, the following C# code:

writer.Formatting = Formatting.Indented;
writer.WriteStartElement("root");
 writer.WriteAttributeString("xmlns","x",null,"urn:abc");
 writer.WriteStartElement("item");
 writer.WriteStartAttribute("href",null);
 writer.WriteString("#");
 writer.WriteQualifiedName("test","urn:abc");
 writer.WriteEndAttribute();
 writer.WriteEndElement();
 writer.WriteEndElement();
 writer.Close();
 

Generates the following output:

<root xmlns:x="urn:abc">
 <item href="#x:test"/>
 </root>
 

If ns maps to the current default namespace, no prefix is generated.

When writing attribute values, this method generates a prefix if ns is not found. When writing element content, it throws an exception if ns is not found.

Example

See WriteQualifiedName (in the XmlTextWriter class) for an example using this method.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

XmlWriter Class | XmlWriter Members | System.Xml Namespace

Show:
© 2015 Microsoft