# System.Xml

**Kind:** Service

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

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

NuGet package dependency

`System.Xml` is a NuGet package dependency declared in `Pams.API.csproj`. It supports XML parsing, serialization, and related XML types used by the Pams API.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant PamsAPI as Pams.API
    participant SystemXml as System.Xml

    Client->>PamsAPI: Send XML request payload
    PamsAPI->>SystemXml: Parse or serialize XML
    SystemXml-->>PamsAPI: XML document or serialized content
    PamsAPI-->>Client: Return API response
```

## Usage

```ts
const xmlPayload = `
  <Request>
    <CustomerId>customer-id</CustomerId>
  </Request>
`;

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

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

const result = await response.json();
console.log(result);
```

## AI Coding Instructions

- Keep XML parsing and serialization inside the Pams API .NET code; JavaScript clients should send XML through API endpoints.
- Check `Pams.API.csproj` before adding XML-related dependencies, since `System.Xml` is already declared as a NuGet package dependency.
- Validate XML input before reading nodes or deserializing payloads.
- Handle malformed XML as an API validation error rather than allowing parser exceptions to reach callers.
