# System.Xml.Linq

**Kind:** Service

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

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

NuGet package dependency

`System.Xml.Linq` is a NuGet package dependency declared by `Pams.Business.csproj`. The business layer uses its LINQ-to-XML types, such as `XDocument` and `XElement`, to read, create, or modify XML data.

## Diagram

```mermaid
flowchart TD
    A[Pams.Business.csproj] --> B[System.Xml.Linq package reference]
    B --> C[Pams.Business C# code]
    C --> D[XDocument and XElement]
    D --> E[XML input or output]
```

## Usage

```ts
import { execFileSync } from "node:child_process";
import path from "node:path";

const projectPath = path.resolve(
  "Pams/Logic/Pams.Business/Pams.Business.csproj"
);

// Restores the NuGet dependency and builds code that references System.Xml.Linq.
execFileSync("dotnet", ["build", projectPath], {
  stdio: "inherit",
});
```

## AI Coding Instructions

- Keep `System.Xml.Linq` references in the `Pams.Business.csproj` package dependency list when business-layer code uses `XDocument` or `XElement`.
- Use `XDocument.Parse`, `XElement`, and LINQ queries for XML handling instead of manual string manipulation.
- Validate XML input before reading expected elements or attributes, since missing nodes can produce null values.
- Run `dotnet build Pams/Logic/Pams.Business/Pams.Business.csproj` after changing package references or XML-related business logic.
