# System.Xml

**Kind:** Service

**Source:** `Pams/Logic/Common/Pams.Common.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`System.Xml` is a NuGet package dependency declared by `Pams.Common.csproj` for XML parsing, reading, and writing in shared PAMS code. Common components can use its .NET XML APIs when handling XML-based configuration, messages, or integrations.

## Diagram

```mermaid
graph TD
  A[Calling component] --> B[Pams.Common]
  B --> C[System.Xml package]
  C --> D[XML reader or writer]
  D --> E[XML document or stream]
```

## Usage

```ts
const xmlPayload = `
<customer>
  <id>abc</id>
  <name>Example Customer</name>
</customer>
`;

const response = await fetch("/api/customers/import-xml", {
  method: "POST",
  headers: {
    "Content-Type": "application/xml",
  },
  body: xmlPayload,
});

if (!response.ok) {
  throw new Error("XML import failed");
}

// The .NET endpoint can parse the request through Pams.Common,
// which references the System.Xml package.
console.log(await response.json());
```

## AI Coding Instructions

- Keep XML parsing and serialization code in shared PAMS components that reference `Pams.Common.csproj`.
- Prefer `XmlReader` for stream-based parsing when a full in-memory document is not required.
- Validate XML input before reading values and handle malformed XML exceptions at integration boundaries.
- Avoid adding another XML package unless the required API is unavailable in `System.Xml`.
