Code Monkey home page Code Monkey logo

welldom's Introduction

Welldom, the XML toolbox for PHP Build Status

Welldom try to ease the use of DOM to manipulate XML documents with the following features :

  • Error management
  • Unique encoding for XML input/output
  • Simple methods to query and manipulate the DOM with Xpath
  • Batch on node list
  • Node rename & remove methods

Requirements

  • PHP 5.3+
  • PHPUnit 5.6+

Installation

The library follow the PSR-0 naming convention. To load the library, use any compliant class loader or simply require the src/autoload.php file.

require __DIR__ . '/path/to/expdom/src/autoload.php';

Usage

Load an XML document:

<?php

use Welldom\Document;

$doc = new Document('UTF-8');

if (false === $doc->load('data.xml')) {
    $errors = $doc->getLastErrors();
    throw new Exception("XML Loading error\n" . implode("\n", $errors));
}

// ... enjoy your DOM document

Find a node values using XPath:

$values = array(
    'title' => $doc->getNodeValue('//book/title'),
    'lang' => $doc->getNodeValue('//book/title/@lang', 'en'),
);

Execute action on each node matching a given Xpath:

$doc->query('//foo/bar[@lang=de]')
    ->remove();

$doc->query('//foo/bar[@lang=english]/@lang')
    ->setValue('en');

Run tests

Run PHPUnit test suite:

phpunit

License

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Contributors:

welldom's People

Contributors

gromnan avatar j0k3r avatar jeromemacias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  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.