Export (0) Print
Expand All
Expand Minimize

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.

Namespace:  System.Xml
Assemblies:   System.Xml (in System.Xml.dll)
  System.Xml.ReaderWriter (in System.Xml.ReaderWriter.dll)

'Declaration
Public Overridable Sub WriteQualifiedName ( _
	localName As String, _
	ns As String _
)

Parameters

localName
Type: System.String

The local name to write.

ns
Type: System.String

The namespace URI for the name.

ExceptionCondition
ArgumentException

localName is either Nothing or String.Empty.

localName is not a valid name.

InvalidOperationException

An XmlWriter method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.”

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.

NoteNote

If a class derived from the XmlWriter does not override this method localName is not checked to be a valid W3C XML name. In such case, before calling this method, the validity of the string can be checked by IsName method.

For the asynchronous version of this method, see WriteQualifiedNameAsync.

The example writes the following element:

<root xmlns:x="urn:abc">
  <item href="#x:test"/>
</root>
Dim settings As New XmlWriterSettings()
settings.Indent = True
settings.OmitXmlDeclaration = True 
Using writer As XmlWriter = XmlWriter.Create(Console.Out, settings)
  writer.WriteStartElement("root")
  writer.WriteAttributeString("xmlns", "x", Nothing, "urn:abc")
  writer.WriteStartElement("item")
  writer.WriteStartAttribute("href", Nothing)
  writer.WriteString("#")
  writer.WriteQualifiedName("test", "urn:abc")
  writer.WriteEndAttribute()
  writer.WriteEndElement()
  writer.WriteEndElement()
End Using

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft