Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml Inheritance: System.ValueTypeSyntax
Summary
Represents a namespace-qualified XML name: a local name, a namespace URI, and an optional prefix.Usage
AnXmlName is a qualified XML name: a local name, a namespace URI, and an optional prefix. The library uses it wherever a name has to carry its namespace, for example XmlTypeInfo.RootName, XmlPropertyInfo.Name, and the keys of XmlExtensionData.Attributes.
Create a name with the local name alone, or add the namespace URI and the prefix:
Remarks
Two names are equal when XmlName.LocalName and XmlName.NamespaceUri are equal by ordinal comparison. XmlName.Prefix only affects how the name is written. It is not used for equality or for mapping.Examples
Compare and print names
ToString returns prefix:local when the name has a prefix, {uri}local when it has a namespace and no prefix, and the local name otherwise.
Considerations
XmlNameis areadonly structthat holds three string references. Copying it is cheap, and creating one allocates nothing beyond the strings you pass in.- The constructor checks only that the local name isn’t
null, empty, or white space. It doesn’t check that the parts are valid XML names. - A
nullnamespace URI or prefix passed to the constructor becomes an empty string, soNamespaceUriandPrefixare nevernullin a name you create. - Comparison is ordinal. Namespace URIs are compared character by character, as the Namespaces in XML recommendation requires, so
urn:Exampleandurn:exampleare different namespaces. - The output of
ToStringis for display. The{uri}localform is not XML syntax. default(XmlName)doesn’t go through the constructor, so itsLocalName,NamespaceUri, andPrefixare allnull. Don’t use it as a name.
Constructors
.ctor
Initializes a new instance of the XmlName struct with the specified local name, namespace URI, and prefix.Syntax
Parameters
Exceptions
Examples
Remarks
Pass a namespace URI without a prefix when the name is only compared with other names. XmlName.ToString writes the prefix only when it is not empty..ctor Inherited
Inherited from
System.ValueTypeSyntax
.ctor Inherited
Inherited from
objectSyntax
Properties
LocalName
Gets the local part of the name.Syntax
Property Value
Type:string
The local name.
NamespaceUri
Gets the namespace URI of the name.Syntax
Property Value
Type:string
The namespace URI, or an empty string if the name is in no namespace.
Prefix
Gets the prefix of the name.Syntax
Property Value
Type:string
The prefix, or an empty string if the name has no prefix.
Methods
Equals
Determines whether this name and a specified XmlName have the same local name and namespace URI.Syntax
Parameters
Returns
Type:bool
true if other has the same local name and namespace URI as this name,
by ordinal comparison; otherwise, false.
Equals Override
Determines whether this name and a specified object are equal.Syntax
Parameters
Returns
Type:bool
true if obj is an XmlName with the same local name and
namespace URI as this name; otherwise, false.
Equals Override
Inherited from
System.ValueTypeSyntax
Parameters
Returns
Type:bool
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetHashCode Override
Returns the hash code for this name, computed from XmlName.LocalName and XmlName.NamespaceUri.Syntax
Returns
Type:int
A 32-bit signed integer hash code.
GetHashCode Override
Inherited from
System.ValueTypeSyntax
Returns
Type:int
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
ToString Override
Returns a string that represents this name.Syntax
Returns
Type:string
prefix:local if the name has a prefix; otherwise, {uri}local if the name has a namespace URI;
otherwise, the local name.
ToString Override
Inherited from
System.ValueTypeSyntax
Returns
Type:string?
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- CloudNimble.Text.Xml.XmlNamespaces
- CloudNimble.Text.Xml.Serialization.XmlExtensionData
- CloudNimble.Text.Xml.Serialization.XmlPropertyInfo
- CloudNimble.Text.Xml.Serialization.XmlTypeInfo
- CloudNimble.Text.Xml.Nodes.XmlElementNode