Login   Register  
PHP Classes
elePHPant
Icontem

File: XmlArrayTest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Augusto Cesar Castoldi  >  XML Array  >  XmlArrayTest.php  >  Download  
File: XmlArrayTest.php
Role: Example script
Content type: text/plain
Description: Examples of storing an array and reading the xml
Class: XML Array
Store and retrieve arrays from XML documents
Author: By
Last change: Updated the sample directory
Date: 11 years ago
Size: 807 bytes
 

Contents

Class file image Download
<?

include_once("class.XmlArray.php");

$path "/home/user/test";

if (
$mode == "createXML")
{
  
$array[0] = "a. first element of array";
  
$array[1] = "b. second element of array";
  
$array[2] = "c. third element of array";
  
$array[3] = "d. fourth element of array";

  
$xml = new XmlArray();
  
$xml->saveXML($array"$path/XmlArrayTest.xml");
  echo 
"<a href=XmlArrayTest.xml target=_blank>open generated xml</a>";
}
else if (
$mode == "readXML")
{
  
$xml = new XmlArray();
  
$array $xml->getArray("$path/XmlArrayTest.xml");

  for (
$i 0$i count($array); $i++)
  {
    echo 
"array[$i] = $array[$i]<br>";
  }
}

?>
<br><br>
<a href="<?="$PHP_SELF?mode=createXML"?>">Create the XML Sample</a>
<br><br>
<a href="<?="$PHP_SELF?mode=readXML"?>">Read the XML Sample</a>