diff --git a/.chronus/changes/feature-xml-2024-2-20-16-48-57.md b/.chronus/changes/feature-xml-2024-2-20-16-48-57.md
new file mode 100644
index 0000000000..a5a0085727
--- /dev/null
+++ b/.chronus/changes/feature-xml-2024-2-20-16-48-57.md
@@ -0,0 +1,8 @@
+---
+# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
+changeKind: internal
+packages:
+ - "@typespec/xml"
+---
+
+Initial release of xml library
diff --git a/.chronus/changes/feature-xml-2024-3-8-20-40-16.md b/.chronus/changes/feature-xml-2024-3-8-20-40-16.md
new file mode 100644
index 0000000000..5cfb83e8b6
--- /dev/null
+++ b/.chronus/changes/feature-xml-2024-3-8-20-40-16.md
@@ -0,0 +1,8 @@
+---
+# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
+changeKind: feature
+packages:
+ - "@typespec/compiler"
+---
+
+`getEncode` returns the fully equalied enum member name if using a custom enum.
diff --git a/docs/libraries/xml/guide.md b/docs/libraries/xml/guide.md
new file mode 100644
index 0000000000..f7860abe97
--- /dev/null
+++ b/docs/libraries/xml/guide.md
@@ -0,0 +1,948 @@
+---
+title: Guide
+---
+
+# Xml Library
+
+## Default encoding of scalars
+
+As in Json we have some [default handling](https://typespec.io/docs/libraries/http/encoding#bytes) of the common scalars like `utcDateTime`
+
+| Scalar Type | Default Encoding | Encoding name |
+| ---------------- | ----------------- | --------------------------------------- |
+| `utcDateTime` | `xs:dateTime` | `TypeSpec.Xml.Encoding.xmlDateTime` |
+| `offsetDateTime` | `xs:dateTime` | `TypeSpec.Xml.Encoding.xmlDateTime` |
+| `plainDate` | `xs:date` | `TypeSpec.Xml.Encoding.xmlDate` |
+| `plainTime` | `xs:time` | `TypeSpec.Xml.Encoding.xmlTime` |
+| `duration` | `xs:duration` | `TypeSpec.Xml.Encoding.xmlDuration` |
+| `bytes` | `xs:base64Binary` | `TypeSpec.Xml.Encoding.xmlBase64Binary` |
+
+## Examples
+
+### 1. Array of primitive types
+
+
+
+ TypeSpec |
+ Xml |
+ OpenAPI3 |
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ @xml.unwrapped
+ tags: string[];
+}
+```
+
+ |
+
+
+```xml
+
+ abc
+ def
+
+```
+
+ |
+
+
+```yaml
+Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ items:
+ type: string
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ @encodedName("application/xml", "ItemsTags")
+ tags: string[];
+}
+```
+
+ |
+
+
+```xml
+
+
+ abc
+ def
+
+
+```
+
+ |
+
+
+```yaml
+Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ xml:
+ name: "ItemsTags"
+ wrapped: true
+ items:
+ type: string
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "ItemsName")
+scalar tag extends string;
+
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ @xml.unwrapped
+ tags: tag[];
+}
+```
+
+ |
+
+
+```xml
+
+ abc
+ def
+
+```
+
+ |
+
+
+```yaml
+Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ xml:
+ name: "ItemsTags"
+ items:
+ type: string
+ xml:
+ name: ItemsName
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "ItemsName")
+scalar tag extends string;
+
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ @encodedName("application/xml", "ItemsTags")
+ tags: tag[];
+}
+```
+
+ |
+
+
+```xml
+
+
+ abc
+ def
+
+
+```
+
+ |
+
+
+```yaml
+Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ xml:
+ name: "ItemsTags"
+ wrapped: true
+ items:
+ type: string
+ xml:
+ name: ItemsName
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+### 2. Complex array types
+
+
+
+ TypeSpec |
+ Xml |
+ OpenAPI3 |
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ @xml.unwrapped
+ tags: Tag[];
+}
+
+@encodedName("application/xml", "XmlTag")
+model Tag {
+ name: string;
+}
+```
+
+ |
+
+
+```xml
+
+
+ string
+
+
+```
+
+ |
+
+
+```yaml
+Tag:
+ type: "object"
+ properties:
+ name:
+ type: "string"
+ xml:
+ name: "XmlTag"
+Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ items:
+ $ref: "#/definitions/Tag"
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ tags: Tag[];
+}
+
+@encodedName("application/xml", "XmlTag")
+model Tag {
+ name: string;
+}
+```
+
+ |
+
+
+```xml
+
+
+
+ string
+
+
+
+```
+
+ |
+
+
+```yaml
+Tag:
+ type: "object"
+ properties:
+ name:
+ type: "string"
+ xml:
+ name: "XmlTag"
+Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ xml:
+ name: "ItemsTags"
+ wrapped: true
+ items:
+ $ref: "#/definitions/Tag"
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ @encodedName("application/xml", "ItemsTags")
+ @xml.unwrapped
+ tags: Tag[];
+}
+
+@encodedName("application/xml", "XmlTag")
+model Tag {
+ name: string;
+}
+```
+
+ |
+
+
+```xml
+
+
+ string
+
+
+```
+
+ |
+
+
+```yaml
+Tag:
+ type: "object"
+ properties:
+ name:
+ type: "string"
+ xml:
+ name: "XmlTag"
+ Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ xml:
+ name: "ItemsTags"
+ items:
+ $ref: "#/definitions/Tag"
+ xml:
+ name: ItemsXMLName
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@encodedName("application/xml", "XmlPet")
+model Pet {
+ @encodedName("application/xml", "ItemsTags")
+ tags: Tag[];
+}
+
+@encodedName("application/xml", "XmlTag")
+model Tag {
+ name: string;
+}
+```
+
+ |
+
+
+```xml
+
+
+
+ string
+
+
+
+```
+
+ |
+
+
+```yaml
+Tag:
+ type: "object"
+ properties:
+ name:
+ type: "string"
+Pet:
+ type: "object"
+ properties:
+ tags:
+ type: "array"
+ xml:
+ name: "ItemsTags"
+ wrapped: true
+ items:
+ $ref: "#/definitions/Tag"
+ xml:
+ name: "XmlPet"
+```
+
+ |
+
+
+
+
+
+### 3. Nested models
+
+
+
+
+ TypeSpec |
+ Xml |
+ OpenAPI3 |
+
+
+
+
+
+```tsp
+model Book {
+ author: Author;
+}
+
+model Author {
+ name: string;
+}
+```
+
+ |
+
+
+```xml
+
+
+ string
+
+
+```
+
+ |
+
+
+```yaml
+Book:
+ type: object
+ properties:
+ author:
+ $ref: "#/components/schemas/Author"
+Author:
+ type: object
+ properties:
+ name:
+ type: string
+```
+
+ |
+
+
+
+
+
+
+```tsp
+model Book {
+ author: Author;
+}
+
+@encodedName("application/xml", "XmlAuthor")
+model Author {
+ name: string;
+}
+```
+
+ |
+
+
+```xml
+
+
+ string
+
+
+```
+
+ |
+
+
+```yaml
+Book:
+ type: object
+ properties:
+ author:
+ allOf:
+ - $ref: "#/components/schemas/Author"
+ xml:
+ name: "author" # Here we have to redefine this name otherwise in OpenAPI semantic the `XmlAuthor` name would be used
+Author:
+ type: object
+ properties:
+ name:
+ type: string
+ xml:
+ name: "XmlAuthor"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+model Book {
+ @encodedName("application/xml", "xml-author")
+ author: Author;
+}
+
+model Author {
+ name: string;
+}
+```
+
+ |
+
+
+```xml
+
+
+ string
+
+
+```
+
+ |
+
+
+```yaml
+Book:
+ type: object
+ properties:
+ author:
+ allOf:
+ - $ref: "#/components/schemas/Author"
+ xml:
+ name: "xml-author"
+Author:
+ type: object
+ properties:
+ name:
+ type: string
+```
+
+ |
+
+
+
+
+
+
+### 4. Attributes
+
+
+
+
+ TypeSpec |
+ Xml |
+ OpenAPI3 |
+
+
+
+
+
+```tsp
+@Xml.ns("smp", "http://example.com/schema")
+model Book {
+ id: string;
+ title: string;
+ author: string;
+}
+```
+
+ |
+
+
+```xml
+
+ 0
+ string
+ string
+
+```
+
+ |
+
+
+```yaml
+Book:
+ type: object
+ properties:
+ id:
+ type: integer
+ title:
+ type: string
+ author:
+ type: string
+ xml:
+ prefix: "smp"
+ namespace: "http://example.com/schema"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@Xml.ns("smp", "http://example.com/schema")
+model Book {
+ id: string;
+
+ @Xml.ns("smp", "http://example.com/schema")
+ title: string;
+
+ @Xml.ns("ns2", "http://example.com/ns2")
+ author: string;
+}
+```
+
+ |
+
+
+```xml
+
+ 0
+ string
+ string
+
+```
+
+ |
+
+
+```yaml
+Book:
+ type: object
+ properties:
+ id:
+ type: integer
+ title:
+ type: string
+ xml:
+ prefix: "smp"
+ namespace: "http://example.com/schema"
+ author:
+ type: string
+ xml:
+ prefix: "ns2"
+ namespace: "http://example.com/ns2"
+ xml:
+ prefix: "smp"
+ namespace: "http://example.com/schema"
+```
+
+ |
+
+
+
+
+
+
+### 6. Namespace and prefix (normalized form)
+
+
+
+
+ TypeSpec |
+ Xml |
+ OpenAPI3 |
+
+
+
+
+
+```tsp
+@Xml.nsDeclarations
+enum Namespaces {
+ smp: "http://example.com/schema",
+}
+
+@Xml.ns(Namespaces.smp)
+model Book {
+ id: string;
+ title: string;
+ author: string;
+}
+```
+
+ |
+
+
+```xml
+
+ 0
+ string
+ string
+
+```
+
+ |
+
+
+```yaml
+Book:
+ type: object
+ properties:
+ id:
+ type: integer
+ title:
+ type: string
+ author:
+ type: string
+ xml:
+ prefix: "smp"
+ namespace: "http://example.com/schema"
+```
+
+ |
+
+
+
+
+
+
+```tsp
+@Xml.nsDeclarations
+enum Namespaces {
+ smp: "http://example.com/schema",
+ ns2: "http://example.com/ns2",
+}
+
+@Xml.ns(Namespaces.smp)
+model Book {
+ id: string;
+
+ @Xml.ns(Namespaces.smp)
+ title: string;
+
+ @Xml.ns(Namespaces.ns2)
+ author: string;
+}
+```
+
+ |
+
+
+```xml
+
+ 0
+ string
+ string
+
+```
+
+ |
+
+
+```yaml
+Book:
+ type: object
+ properties:
+ id:
+ type: integer
+ title:
+ type: string
+ xml:
+ prefix: "smp"
+ namespace: "http://example.com/schema"
+ author:
+ type: string
+ xml:
+ prefix: "ns2"
+ namespace: "http://example.com/ns2"
+ xml:
+ prefix: "smp"
+ namespace: "http://example.com/schema"
+```
+
+ |
+
+
+
+
+
+
+### 6. Property setting the text of the node
+
+