Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sanusart/sxml
This class will assist in very basic XML document creation.
https://github.com/sanusart/sxml
Last synced: about 1 month ago
JSON representation
This class will assist in very basic XML document creation.
- Host: GitHub
- URL: https://github.com/sanusart/sxml
- Owner: sanusart
- License: mit
- Created: 2014-01-27T21:39:43.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-10-19T18:08:53.000Z (over 10 years ago)
- Last Synced: 2024-10-30T06:27:28.459Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 211 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# sXml - Simplest, basic XML document creation
---
This class will assist in very basic XML document creation.
## Autoload (with composer)
Add `"sanusart/sxml": "dev-master"` to require array in `composer.json`
Use as:
```
5.4.0 and `php-cli` - you can run `php -s localhost:8080` inside *example* directory.## Basic usage
```
doctype();
$xml->open('users', array('requered' => 'true', 'type' => 'meta'));$xml->open('user');
$xml->node('name', 'Sasha');
$xml->node('last_name', 'Khamkov');
$xml->node('alias', 'sanusart');
$xml->node('twitter', '@sanusart');
$xml->node('website', 'http://www.sanusart.com');
$xml->close('user');$xml->open('no_closing_tag');
$xml->node('node', null, array('requered' => 'true', 'type' => 'data'));
$xml->node('node', null, array('requered' => 'false', 'type' => 'data'));
$xml->node('node', null);
$xml->close('no_closing_tag');$xml->close('users');
```
will result in:```
```
## Methods
### Constructor()
If `$safe` is set to true - values of XML nodes will be enclosed inside CDATA
```
Constructor __construct
sXml __construct ([bool $safe = false])
```### doctype()
_access: public_Ommiting method attributes for `$version` and/or `$encoding` will use default values.
```
void doctype ([string $version = '1.0'], [string $encoding = 'utf=8'])
string $version (optional)
string $encoding (optional)
```### open()
_access: public_
```
void open ([string $tag], [array $attr = array()])
string $tag
array $attr (optional)
```### close()
_access: public_
```
void close ([string $tag])
string $tag
```### node()
_access: public_If `$value` is set - regular node with closing tag will be created e.g. ``. To create a self closed tag `` set `$value` to `null`.
```
void node ([string $tag], [mixed $value], [array $attr = array()])
string $tag
mixed $value | null
array $attr (optional)
```