PHP code example of pepve / dom-creator
1. Go to this page and download the library: Download pepve/dom-creator library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pepve / dom-creator example snippets
<?
$foo = DomCreator::create('http://example.com/foo', 'f', 'foo');
$foo->ident->name = 'John Doe';
$foo->ident->number = '123';
$foo->content = 'Hello, World!';
<?
$foo = DomCreator::create('http://example.com/foo', 'f', 'foo');
$foo->ident->_type = 'person';
$foo->ident->name = 'My Name';
$foo->ident->number = '1234';
$foo->content = 'Here is the content..';
$fooDom = $foo->getDocument();
$fooDom->formatOutput = true;
echo $fooDom->saveXml();
<?
$bar = DomCreator::createNoNamespace('Bar');
$bar->One = 1;
$bar->Two = 2;
$bar->Three = 3;
$subBar = DomCreator::createFragmentNoNamespace();
foreach (array('A', 'B') as $i => $letter)
{
$subBar->Letter->Sequence = $i;
$subBar->Letter->Value = $letter;
$subBar->closeChild();
}
$bar->Sub = $subBar;
$dom = new DOMDocument();
$dom->appendChild($dom->createElement('Test', 'value'));
$bar->DomPart = $dom;
$barDom = $bar->getDocument();
$barDom->formatOutput = true;
echo $barDom->saveXml();