Code Monkey home page Code Monkey logo

xml-converter's Introduction

PHP XML Converter

SensioLabsInsight Code Climate Test Coverage Latest Stable Version Build Status

A PHP XML parser class that provides an easy way to convert XML into native PHP arrays and back again. It has no dependencies on any external libraries or extensions bundled with PHP. The entire parser is concisely written in PHP.

This project is actively maintained. It is used in our production code. If you spot an issue, please let us know through the Issues section on our Github project page: https://github.com/greencape/xml-converter/issues

In short, this project makes sense for those who want to simplify their PHP install and use, have a need for a simple XML parser, but don't much care about speed.

Requirements

PHP 5.4+

Installation

Composer

Simply add a dependency on greencape/xml-converter to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a dependency on XML Converter:

{
    "require": {
        "greencape/xml-converter": "*@dev"
    }
}

For a system-wide installation via Composer, you can run:

composer global require 'greencape/xml-converter=*'

Make sure you have ~/.composer/vendor/bin/ in your path.

Usage Examples

XML String to PHP Array

<?php

$xml = new \GreenCape\Xml\Converter('<?xml version="1.0" encoding="ISO-8859-1"?>
<breakfast_menu>
	<food>
		<name>Waffles</name>
	</food>
</breakfast_menu>');
var_dump($xml->data);

?>

XML File to PHP Array

<?php
$xml = new \GreenCape\Xml\Converter('some_xml_file.xml');
var_dump($xml->data);

?>

PHP Array to XML String

<?php
$xml = new \GreenCape\Xml\Converter(array(
	'breakfast_menu' => array(
		array(
			'food' => array(
				'name' => 'Waffles'
			)
		)
	)
));
echo $xml;

?>

xml-converter's People

Contributors

nibra avatar

Watchers

James Cloos avatar Jan Holthuis avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.