0.7.1 • Published 2 years ago

@infomaker/xml-handler v0.7.1

Weekly downloads
20
License
Unlicense
Repository
bitbucket
Last release
2 years ago

XML handler client

A Client library simplifying working with XML.

Install

npm install -s @infomaker/xml-handler

Test

To run project test once use:

npm run test

or to enable auto-reload of test on save use:

npm run test-watch

Import

import XmlHandler from '@infomaker/xml-handler'

Publish a new release

Use GitFlow with master/develop/feature/release branches to handle new functionality and versions. When a new release-branch has been created run one of the following scripts to bump-version, create a tag and commit new changes.

    npm run release:major
    npm run release:minor
    npm run release:hotfix

How to use

// Supports either xml-string or xml-document (will create own document if served with xml-string)
this.xmlHandler = new XmlHandler(this.conceptXml)

// Will transform xpath v. 2.0 wildcard namespace into 1.0 friendly value
// /*:conceptItem/*:itemMeta/*:links/*:link[@type='x-im/social+facebook'][@rel='irel:seeAlso']/@url
// /*[local-name(.) = 'conceptItem']/*[local-name(.) = 'itemMeta']/*[local-name(.) = 'links']/*[local-name(.) = 'link'][@type='x-im/social+twitter'][@rel='irel:seeAlso']/@url
const node = this.xmlHandler.getSafeNode(xpath)
const nodeValue = this.xmlHandler.getNodeValue(node)

// If the xpath doesent resolve to a node, create it like so:

if (!this.getSafeNode(xpath)) {
    // Will create all nodes down to the last expression in the xpath
    this.xmlHandler.createNodes(xpath)    
    this.xmlHandler.setNodeValue(node, value)
}

// Remove node
const isRemoved = this.xmlHandler.removeNode(node)
if (isRemoved) {
    console.log('Node has been removed')
}
0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.9

6 years ago

0.0.10

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.4

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago