PHP Classes

File: manuscript/Working with Pimf_Util_Xml.md

Recommend this page to a friend!
  Classes of Gjero Krsteski   PIMF   manuscript/Working with Pimf_Util_Xml.md   Download  
File: manuscript/Working with Pimf_Util_Xml.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: PIMF
Framework for Web application development
Author: By
Last change: Update of manuscript/Working with Pimf_Util_Xml.md
Date: 5 months ago
Size: 1,126 bytes
 

Contents

Class file image Download

Xml

An XML util for converting XML to DOMDocument or SimpleXMLElement or to Array.

Convert string to SimpleXml instance

$string    = file_get_contents('path/to/samp.xml');
$simpleXml = Pimf\Util\Xml::toSimpleXMLElement($string);

Convert file to SimpleXml instance

$file      = 'path/to/samp.xml';
$simpleXml = Pimf\Util\Xml::toSimpleXMLElement($file);

Convert string to DOMDocument instance

$string = file_get_contents('path/to/samp.xml');
$dom    = Pimf\Util\Xml::toDOMDocument($string);

Convert file to DOMDocument instance

$file = 'path/to/samp.xml';
$dom  = Pimf\Util\Xml::toDOMDocument($file);

Convert SimpleXml instance to array

$file      = 'path/to/samp.xml';
$simpleXml = Pimf\Util\Xml::toSimpleXMLElement($file);
$result    = Pimf\Util\Xml::toArray($simpleXml);

Convert SimpleXml to array using namespace

$namespace = 'pimf'; //The XML namespace that should be fetched.
$file      = 'path/to/samp-with-namespace.xml';
$simpleXml = Pimf\Util\Xml::toSimpleXMLElement($file);
$result    = Pimf\Util\Xml::toArray($simpleXml, $namespace);