0.0.7 • Published 2 years ago

xml-pipe v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

XmlPipe

Angular Pipe which converts a value into its XML-format representation.

Installation

Peer dependency

The package uses the peer dependency 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.

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.

{{ value | xml : prettyPrint : root }}

Arguments

ParamTypeDefault ValueDetails
valueobjectThe object to be displayed in XML representation.
prettyPrintbooleanfalseWhether the XML elements should be indented according to their level.
rootstringName of an optional root element to be added.

Examples

Default usage

foo = { foo :  'bar' }
{{ foo | xml }}

Result:

<?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.

foo = { name:  "Lisa Simpson", address: { street :  "742 Evergreen Terrace", city:  "Springfield" }}
{{{ foo : false : 'character' }}}

Result:

<?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.

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago