# xml-pipe

Latest version **0.0.7** (published 2021-12-21) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install xml-pipe
pnpm add xml-pipe
yarn add xml-pipe
bun add xml-pipe
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2021-12-21 |
| First published | 2021-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Franz Bernack |
| Maintainers | dafant |
| Keywords | xml, angular, pipe |

## Links

- npm: https://www.npmjs.com/package/xml-pipe
- Repository: https://github.com/daFant/xml-pipe
- Issues: https://github.com/daFant/xml-pipe/issues
- npm.io page: https://npm.io/package/xml-pipe

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2021-12-21
- 0.0.6 — 2021-12-20
- 0.0.5 — 2021-12-20
- 0.0.4 — 2021-12-20
- 0.0.3 — 2021-12-20
- 0.0.2 — 2021-12-20
- 0.0.1 — 2021-12-20

## README

# XmlPipe

<p align="center">
<a href="https://www.npmjs.com/package/xml-pipe"><img src="https://img.shields.io/npm/v/xml-pipe.svg?style=flat-square" alt="npm"></a>
<a href="https://github.com/daFant/xml-pipe/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="MIT licensed"></a><br/><br/>

Angular Pipe which converts a value into its XML-format representation.
</p>


## Installation

### Peer dependency

The package uses the peer dependency [xmlbuilder2](https://github.com/oozcitak/xmlbuilder2), so this must be installed first.

`npm i xmlbuilder2`

### Install XmlPipe

Use npm to install the package:
```
npm i xml-pipe
```

Or install using `ng add`:
```
ng add xml-pipe
```

## Usage

1) Register the `XmlPipeModule` in your app module.

 ```typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { XmlPipeModule } from 'XmlPipe';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    XmlPipeModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
 ```

 2) Use the `xml` pipe in your template expression.

```html
{{ value | xml : prettyPrint : root }}
```
### Arguments

| Param | Type | Default Value | Details |
| --- | --- | --- | --- |
| value | `object` |  | The object to be displayed in XML representation. |
| prettyPrint | `boolean` | false | Whether the XML elements should be indented according to their level. |
| root | `string` |  | Name of an optional root element to be added. |
 
### Examples
#### Default usage
```typescript
foo = { foo :  'bar' }
```
```html
{{ foo | xml }}
```
Result: 
```xml
<?xml version="1.0"?><foo>bar</foo>
```
#### Additional root element
Note: If your object has multiple properties at the first level, a root element must be added, otherwise a valid XML document cannot be displayed.
```typescript
foo = { name:  "Lisa Simpson", address: { street :  "742 Evergreen Terrace", city:  "Springfield" }}
```
```html
{{{ foo : false : 'character' }}}
```
Result: 
```xml
<?xml version="1.0"?><character><name>Lisa Simpson</name><adress><street>742 Evergreen Terrace</street><city>Springfield</city></adress></character>
```

## Credits

This project is based on [xmlbuilder2](https://github.com/oozcitak/xmlbuilder2).

---
_Source: https://npm.io/package/xml-pipe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
