PHP Classes

File: vendor/soothsilver/dtd-parser/README.md

Recommend this page to a friend!
  Classes of stefan   PHP XML Converter   vendor/soothsilver/dtd-parser/README.md   Download  
File: vendor/soothsilver/dtd-parser/README.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: PHP XML Converter
Transform Indesign to eBundesanzeiger XML format
Author: By
Last change:
Date: 1 year ago
Size: 1,322 bytes
 

Contents

Class file image Download

Soothsilver PHP DTD Parser

This is a DTD parser contained a single PHP file that aims to be compliant to the full XML specification. The traditional method of reading XML files in PHP is to use the built-in functions based on libxml2. However, these do not allow you to read and parse Document Type Definition (DTD) files, they only tell you if the DTD is well-formed or not.

With this library, you can parse a DTD file and extract from it general and parameter entities, notations, element definitions and their attribute definitions and also processing instructions.

Examples

Print all declared entities

<?php
$dtd = \Soothsilver\DtdParser\DTD::parseText(file_get_contents("mydtd.dtd"));
foreach($dtd->generalEntities as $entity)
{
 echo $entity->Name . ": " . $entity->replacementText . "\n";
}
foreach($dtd->parameterEntities as $entity)
{
 echo $entity->Name . ": " . $entity->replacementText . "\n";
}

Installation instruction

You can either install this parser via Composer. The package name is soothsilver/dtd-parser. Use the following composer.json file to require it:

{
 "require" : {
  "soothsilver/dtd-parser" : "dev-master" 
 }
}

Alternatively, you may simply include or require the only file this parser is made of:

require_once __DIR__ . 'SoothsilverDtdParser.php';