jvon_mobile/node_modules/cordova-android/node_modules/plist
Chris Cromer 27c42a55c8 Initial commit
Signed-off-by: Chris Cromer <chris@cromer.cl>
2018-10-07 21:10:39 -03:00
..
dist Initial commit 2018-10-07 21:10:39 -03:00
examples/browser Initial commit 2018-10-07 21:10:39 -03:00
lib Initial commit 2018-10-07 21:10:39 -03:00
.jshintrc Initial commit 2018-10-07 21:10:39 -03:00
.travis.yml Initial commit 2018-10-07 21:10:39 -03:00
History.md Initial commit 2018-10-07 21:10:39 -03:00
LICENSE Initial commit 2018-10-07 21:10:39 -03:00
Makefile Initial commit 2018-10-07 21:10:39 -03:00
README.md Initial commit 2018-10-07 21:10:39 -03:00
index.js Initial commit 2018-10-07 21:10:39 -03:00
package.json Initial commit 2018-10-07 21:10:39 -03:00

README.md

plist.js

Mac OS X Plist parser/builder for Node.js and browsers

Sauce Test Status

Build Status

Provides facilities for reading and writing Mac OS X Plist (property list) files. These are often used in programming OS X and iOS applications, as well as the iTunes configuration XML file.

Plist files represent stored programming "object"s. They are very similar to JSON. A valid Plist file is representable as a native JavaScript Object and vice-versa.

Usage

Node.js

Install using npm:

$ npm install --save plist

Then require() the plist module in your file:

var plist = require('plist');

// now use the `parse()` and `build()` functions
var val = plist.parse('<plist><string>Hello World!</string></plist>');
console.log(val);  // "Hello World!"

Browser

Include the dist/plist.js in a <script> tag in your HTML file:

<script src="plist.js"></script>
<script>
  // now use the `parse()` and `build()` functions
  var val = plist.parse('<plist><string>Hello World!</string></plist>');
  console.log(val);  // "Hello World!"
</script>

API

Parsing

Parsing a plist from filename:

var fs = require('fs');
var plist = require('plist');

var obj = plist.parse(fs.readFileSync('myPlist.plist', 'utf8'));
console.log(JSON.stringify(obj));

Parsing a plist from string payload:

var plist = require('plist');

var xml =
  '<?xml version="1.0" encoding="UTF-8"?>' +
  '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' +
  '<plist version="1.0">' +
    '<key>metadata</key>' +
    '<dict>' +
      '<key>bundle-identifier</key>' +
      '<string>com.company.app</string>' +
      '<key>bundle-version</key>' +
      '<string>0.1.1</string>' +
      '<key>kind</key>' +
      '<string>software</string>' +
      '<key>title</key>' +
      '<string>AppName</string>' +
    '</dict>' +
  '</plist>';

console.log(plist.parse(xml));

// [
//   "metadata",
//   {
//     "bundle-identifier": "com.company.app",
//     "bundle-version": "0.1.1",
//     "kind": "software",
//     "title": "AppName"
//   }
// ]

Building

Given an existing JavaScript Object, you can turn it into an XML document that complies with the plist DTD:

var plist = require('plist');

var json = [
  "metadata",
  {
    "bundle-identifier": "com.company.app",
    "bundle-version": "0.1.1",
    "kind": "software",
    "title": "AppName"
  }
];

console.log(plist.build(json));

// <?xml version="1.0" encoding="UTF-8"?>
// <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
// <plist version="1.0">
//   <key>metadata</key>
//   <dict>
//     <key>bundle-identifier</key>
//     <string>com.company.app</string>
//     <key>bundle-version</key>
//     <string>0.1.1</string>
//     <key>kind</key>
//     <string>software</string>
//     <key>title</key>
//     <string>AppName</string>
//   </dict>
// </plist>

License

(The MIT License)