> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# KnownNamespaces

> Provides the namespace declarations of well-known XML formats, each as the prefixes the format is customarily written with and the namespace URIs they are bo...

## Definition

**Assembly:** CloudNimble.XmlEssentials.dll

**Namespace:** CloudNimble.Text.Xml

## Syntax

```csharp theme={"dark"}
CloudNimble.Text.Xml.KnownNamespaces
```

## Summary

Provides the namespace declarations of well-known XML formats, each as the prefixes the format is
customarily written with and the namespace URIs they are bound to.

## Usage

`KnownNamespaces` holds the namespace declarations of well-known XML formats, each as the prefixes the format is customarily written with and the namespace URIs they're bound to. Assign one to `XmlSerializerOptions.Namespaces`, and the serializer declares every namespace of the set on the document element and writes each element and attribute in one of them with the set's prefix.

In the sample, `PodcastShow` is written as `rss`, and its `Author` property is an element in the iTunes namespace:

```csharp theme={"dark"}
var options = new XmlSerializerOptions { Namespaces = KnownNamespaces.Podcast, WriteIndented = true, NewLine = "\n", OmitXmlDeclaration = true };
var show = new PodcastShow { Title = "Field Notes", Author = "Contoso Radio" };

output.WriteLine(XmlSerializer.Serialize(show, options));
```

```xml theme={"dark"}
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:podcast="https://podcastindex.org/namespace/1.0" xmlns:psc="http://podlove.org/simple-chapters" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
  <itunes:author>Contoso Radio</itunes:author>
  <title>Field Notes</title>
</rss>
```

[View the complete sample on GitHub](https://github.com/CloudNimble/XmlEssentials/blob/main/src/CloudNimble.XmlEssentials.Samples/14_Namespaces.cs)

What to know:

* **Every declaration of the set is written,** whether or not the document uses it. The sample uses only `itunes`.
* **A set holds the namespaces a format adds to its own.** A format whose own elements have no namespace, such as RSS, or are customarily in the default namespace, such as a sitemap, isn't in its set.
* **The sets are read-only,** and their declarations are in alphabetical order of prefix.
* **The prefixes matter only when the serializer writes.** When it reads, it compares namespace URIs, so a document that uses other prefixes reads the same.
* **To use the prefixes of a particular document instead,** pass it to `XmlDocument.DiscoverNamespaces` and assign the result to `XmlSerializerOptions.Namespaces`.

For the other ways to choose prefixes, see [Use XML namespaces](https://easyaf.nimbleapps.cloud/xmlessentials/guides/namespaces.md).

## Remarks

Assign one of these to [XmlSerializerOptions.Namespaces](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlSerializerOptions.md#namespaces) to have the serializer declare the
namespaces on the document element and write the customary prefixes. Every declaration of a set is
written, whether or not the document uses it. The sets are read-only, and their declarations are in
alphabetical order of prefix.

A set holds the namespaces a format adds to its own. A format whose own elements have no namespace, such
as RSS, or are customarily written in the default namespace, such as a sitemap, is not in its set. To use
the prefixes of a particular document instead, see
[XmlDocument.DiscoverNamespaces](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlDocument.md#discovernamespaces).

## Examples

```csharp theme={"dark"}
var options = new XmlSerializerOptions { Namespaces = KnownNamespaces.Podcast };
string xml = XmlSerializer.Serialize(feed, options);
```

## Properties

### &#x20;Edmx

Gets the namespace of an OData version 4 metadata document (CSDL in XML), which is customarily written
with the `edmx` prefix.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> Edmx { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`edmx`. The Entity Data Model namespace of the `Schema` element is not in the set: it is
customarily the default namespace of that element.

### &#x20;Podcast

Gets the namespaces of a podcast feed: the iTunes and Podcasting 2.0 extensions to RSS, and the modules
that podcast hosts add.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> Podcast { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`atom`, `content`, `dc`, `googleplay`, `itunes`, `media`,
`podcast` (Podcasting 2.0, the Podcast Index namespace), `psc` (Podlove Simple Chapters)
and `sy`.

### &#x20;Rss

Gets the namespaces of the modules that RSS 2.0 feeds commonly use.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> Rss { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`atom`, `content`, `dc`, `georss`, `media`, `slash`, `sy` and
`wfw`.

### &#x20;Sitemap

Gets the namespaces of the extensions to a sitemap.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> Sitemap { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`image`, `news`, `video` and `xhtml`.

### &#x20;Soap11

Gets the namespaces of a SOAP 1.1 message.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> Soap11 { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`soap`, `xsd` and `xsi`.

#### Remarks

The `soap` prefix is the one .NET and most toolkits write. The specification's own examples use
`SOAP-ENV`.

### &#x20;Soap12

Gets the namespaces of a SOAP 1.2 message.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> Soap12 { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`soap`, `xsd` and `xsi`.

#### Remarks

The `soap` prefix is the one .NET and most toolkits write. The specification's own examples use
`env`.

### &#x20;Svg

Gets the namespaces of an SVG picture.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> Svg { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`svg` and `xlink`.

### &#x20;XmlSchema

Gets the namespaces of XML Schema: the schema language, and the attributes an instance document takes
from it.

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IReadOnlyDictionary<string, string> XmlSchema { get; }
```

#### Property Value

Type: `System.Collections.Generic.IReadOnlyDictionary<string, string>`
`xsd` and `xsi`.

## Related APIs

* CloudNimble.Text.Xml.XmlSerializerOptions
* CloudNimble.Text.Xml.XmlNamespaces
* CloudNimble.Text.Xml.XmlDocument


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.