Modules@robinpath/xml

@robinpath/xml

0.1.0Public

Parse, build, query, and validate XML data

@robinpath/xml

Parse, build, query, and validate XML data

Category Functions Auth License

Why use this module?

The xml module lets you:

  • Parse an XML string into a JavaScript object
  • Convert a JavaScript object into an XML string
  • Read an XML file from disk and parse it into a JavaScript object
  • Convert a JavaScript object to XML and write it to a file
  • Check whether an XML string is well-formed and valid

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/xml

Quick Start

No credentials needed — start using it right away:

xml.stringify $data

Available Functions

FunctionDescription
xml.parseParse an XML string into a JavaScript object
xml.stringifyConvert a JavaScript object into an XML string
xml.parseFileRead an XML file from disk and parse it into a JavaScript object
xml.writeFileConvert a JavaScript object to XML and write it to a file
xml.isValidCheck whether an XML string is well-formed and valid
xml.queryParse XML and retrieve a value at a dot-separated path
xml.toJSONParse an XML string and return its JSON string representation
xml.fromJSONParse a JSON string and build an XML string from it
xml.getAttributeRetrieve an attribute value from an element at a given path
xml.countCount the number of elements at a given path in an XML string

Examples

Convert a JavaScript object into an XML string

xml.stringify $data

Read an XML file from disk and parse it into a JavaScript object

xml.parseFile "/tmp/data.xml"

Convert a JavaScript object to XML and write it to a file

xml.writeFile "/tmp/output.xml" $data

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/xml";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  xml.stringify $data
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/xml
Version0.1.0
LicenseMIT
Unpacked Size4.6 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

utilities