https://github.com/scalajs-io/xml2js
Simple XML to JavaScript object converter.
https://github.com/scalajs-io/xml2js
node nodejs npm npm-package scala scalajs xml2js
Last synced: 4 months ago
JSON representation
Simple XML to JavaScript object converter.
- Host: GitHub
- URL: https://github.com/scalajs-io/xml2js
- Owner: scalajs-io
- License: apache-2.0
- Created: 2017-02-09T04:59:53.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-07T17:32:30.000Z (over 5 years ago)
- Last Synced: 2025-01-17T22:42:26.022Z (5 months ago)
- Topics: node, nodejs, npm, npm-package, scala, scalajs, xml2js
- Language: Scala
- Size: 19.5 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Xml2js API for Scala.js
================================
[xml2js](https://www.npmjs.com/package/xml2js) - Simple XML to JavaScript object converter.### Description
Simple XML to JavaScript object converter. It supports bi-directional conversion. Uses sax-js and xmlbuilder-js.
Note: If you're looking for a full DOM parser, you probably want [JSDom](https://github.com/scalajs-io/jsdom).
### Build Dependencies
* [SBT v1.2.x](http://www.scala-sbt.org/download.html)
### Build/publish the SDK locally
```bash
$ sbt clean publish-local
```### Running the tests
Before running the tests the first time, you must ensure the npm packages are installed:
```bash
$ npm install
```Then you can run the tests:
```bash
$ sbt test
```### Examples
```scala
import io.scalajs.JSON
import io.scalajs.npm.xml2js._
import scalajs.jsval xml = "Hello xml2js!"
Xml2js.parseString[MyObject](xml, (err, result) => {
println("results: " + JSON.stringify(result)) // results: {"root":"Hello xml2js!"}
println(result.root) // Hello xml2js!
})@js.native
trait MyObject extends js.Object {
var root: String = js.native
}
```### Artifacts and Resolvers
To add the `Xml2js` binding to your project, add the following to your build.sbt:
```sbt
libraryDependencies += "io.scalajs.npm" %%% "xml2js" % "0.5.0"
```Optionally, you may add the Sonatype Repository resolver:
```sbt
resolvers += Resolver.sonatypeRepo("releases")
```