WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : ini file to XML converter
Categories : PHP, XML Click here to Update Your Picture
Exception e
Date : Jul 30th 2005
Grade : 2 of 5 (graded 2 times)
Viewed : 8494
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Exception e
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
/**
* parses a ini file into a xml
* If $useSections is true, then evey setting must fall under a section.<br>For more information about the format of ini-files, have a look at the function <code>parse_ini_file()</code> in the php manual.
* @param        string $filePath
* @param        bool $useSections determine whether the ini-settings must be grouped by there sections
* @return        DomDocument holding a xml representation of the ini-file
*/
function iniToXML($filePath, $useSections = false)        {
        $aIni = parse_ini_file($filePath, $useSections);
        $dom = new DOMDocument('1.0', 'iso-8859-1');
        $root = $dom->appendChild($dom->createElement('root'));
        if (!$useSections)        {
                appendIniSettings($root, $aIni);
        } else        {
                foreach ($aIni as $sectionName => $iniSettings)        {
                        $section = $root->appendChild($dom->createElement('section'));
                        $section->setAttribute('name', $sectionName);
                        appendIniSettings($section, $iniSettings);
                }
        }
        return $dom;
}

function appendIniSettings($element, $iniSettings)        {
        $doc = $element->ownerDocument;
        foreach ($iniSettings as $prop => $value)        {
                $setting = $element->appendChild($doc->createElement('setting', $value));
                $setting->setAttribute('name', $prop);
        }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Convert flat ini file into xml</title>
</head>

<body>
NOTE: this code requires at least php5!
<?php
/* EXAMPLE OF USAGE */

        // Convert ini file into XML, with use of sections
$iniXML = iniToXML('sample.ini', true);
        //use formatOuput to create a nice indention, but it is only used for aesthetical reasons
$iniXML->formatOutput = true;
        // Now we can print the resulting xml
echo '<pre>'.htmlentities($iniXML->saveXML()).'</pre>';
        // or write it to a file named sample.xml
file_put_contents('sample.xml', $iniXML->saveXML());
?>
</body>
</html>
;** FILE sample.ini
; Save this file as sample.ini in the same directory as the example php file.

; This is a sample configuration file
; Comments start with ';', as in php.ini
[database]
datebaseName        = test_db
dabatebaseUser        = userA
datebasePass        = secure

[application]
caching = false


[other section]
property = value



utf8_decode -- Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1.
Categories : PHP, PHP Functions, XML
RSS parser using PHP5 and simpleXML
Categories : Rich Site Summary (RSS), PHP, XML
php Free chat simple fast and customizable chat server that uses a simple filesystem for message and nickname storage
Categories : PHP, AJAX, XML, Complete Programs
DBXML- A Class to backup databases in XML Format using web interface
Categories : PHP, PHP Classes, Databases, MySQL, XML
Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript.
Categories : PHP, Java Script, DOM XML, XML, Arrays
SAPIPROCESSOR - is a compact XML-based CMS toolkit
Categories : PHP, Content Management, XML
XML Menu
Categories : PHP, PHP Classes, Navigation, XML, XSL
A very basic and fast XML parser
Categories : PHP, PHP Classes, XML
Glossword - glossary compiler
Categories : Content Management, PHP, MySQL, XML
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
XML easy parser
Categories : PHP, XML, PHP Classes
logger class (PHP5 +)
Categories : PHP, PHP Classes, Log Files, XML
XPath for PHP without the DOM XML extension
Categories : DOM XML, XML, XSLT, PHP Classes, PHP
On-the-fly drop down menu from a txt or xml file
Categories : PHP, XML, HTML and PHP
RSS parser. Parses RSS into an array. Quick and nasty but does the job. No checking is done for correct Tags, only correct XML. PHP4 needed to display result (uses print_r).
Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS)