2017 © Pedro Peláez
 

library tale-dom

XML and HTML manipulation

image

talesoft/tale-dom

XML and HTML manipulation

  • Saturday, May 21, 2016
  • by TorbenKoehn
  • Repository
  • 3 Watchers
  • 0 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Tale Dom

A Tale Framework Component, (*1)

What is Tale Dom?

Installation

Install via Composer, (*2)

composer require "talesoft/tale-dom:*"
composer install

Usage

Parsing


use Tale\Dom; $element = Dom::fromString('

Hello World!

'); var_dump($element->getName()); //h1 var_dump($element->getText()); //Hello World!

Manipulation


use Tale\Dom; $m = Dom::manipulate('<config />'); $m->append('db') ->append('host')->setText('localhost') ->after('password')->setText('12345') ->parent ->after('logging') ->append('adapter')->setText('file') ->append('path')->setText('./errors.log') echo $m; //<config><db><host>localhost</host><password>12345</password>...</config>

...or shorter..., (*3)


use Tale\Dom; $m = Dom::manipulate(' <config> <db> <host /> <password /> </db> <logging> <adapter /> <path id="logPath" /> </logging> </config>'); $m->query('host')->setText('localhost'); $m->query('db > password')->setText('12345'); $m->query('logging adapter')->setText('file'); $m->query('#logPath')->setText('./errors.log'); echo $m; //<config><db><host>localhost</host><password>12345</password>...</config>

...or even shorter..., (*4)


use Tale\Dom; $m = Dom::manipulate([ 'config' => [ 'host' => 'localhost', 'password' => '12345' ], 'logging' => [ 'adapter' => 'file', 'path#logPath' ] ]); $m->query('#logPath')->setText('./errors.log'); echo $m; //<config><db><host>localhost</host><password>12345</password>...</config>

Dumping


use Tale\Dom; $element = Dom::fromString([ 'html' => [ 'head' => [ 'meta[charset="utf-8"]', 'title' => 'My awesome Tale Dom Website!' ] ] ]); $prettyFormatter = new Dom\Formatter(['pretty' => true]); $htmlFormatter = new Dom\Html\Formatter(['pretty' => true]); echo $element; //<html><head><meta charset="utf-8" /><title>...</html> echo $element->getString($prettyFormatter); /* <html> <head> <meta charset="utf-8" /> <title>My awesome Tale Dom Website!</title> ... </html> */ echo $element->getString($htmlFormatter); /* <html> <head> <meta charset="utf-8"> <title>My awesome Tale Dom Website!</title> ... </html> */

The Versions

21/05 2016

dev-master

9999999-dev http://docs.talesoft.io/tale-framework/tale/dom

XML and HTML manipulation

  Sources   Download

MIT

The Requires

 

by Torben Koehn

write xml html markup parse svg xhtml

21/05 2016

0.1

0.1.0.0 http://docs.talesoft.io/tale-framework/tale/dom

XML and HTML manipulation

  Sources   Download

MIT

The Requires

 

by Torben Koehn

write xml html markup parse svg xhtml