Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including simple-plist with all npm packages installed. Try it out:

var simplePlist = require("simple-plist")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

simple-plist v1.1.0

A wrapper utility for interacting with plist data.

node-simple-plist

npm npm Travis (.com) branch

A simple API for interacting with binary and plain text plist data.

Installation

$ npm install simple-plist

Reading Data

var plist = require('simple-plist')

// Read data from a file (xml or binary) (asynchronous)
plist.readFile('/path/to/some.plist', function(err, data) {
  if (err) {
    throw err
  }
  console.log(JSON.stringify(data))
})

// Read data from a file (xml or binary) (synchronous)
var data = plist.readFileSync('/path/to/some.plist')
console.log(JSON.stringify(data))

Writing Data

var plist = require('simple-plist'),
  data = plist.readFileSync('/path/to/some.plist')

// Write data to a xml file (asynchronous)
plist.writeFile('/path/to/plaintext.plist', data, function(err) {
  if (err) {
    throw err
  }
})

// Write data to a xml file (synchronous)
plist.writeFileSync('/path/to/plaintext.plist', data)

// Write data to a binary plist file (asynchronous)
plist.writeBinaryFile('/path/to/binary.plist', data, function(err) {
  if (err) {
    throw err
  }
})

// Write data to a binary plist file (synchronous)
plist.writeBinaryFileSync('/path/to/binary.plist', data)

Mutating Plists In Memory

var plist = require('simple-plist')

// Convert a Javascript object to a plist xml string
var xml = plist.stringify({ name: 'Joe', answer: 42 })
console.log(xml) // output is a valid plist xml string

// Convert a plist xml string or a binary plist buffer to a Javascript object
var data = plist.parse(
  '<plist><dict><key>name</key><string>Joe</string></dict></plist>'
)
console.log(JSON.stringify(data))
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free