Login   Register  
PHP Classes
elePHPant
Icontem

File: array2xml.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Kirill Shvakov  >  Simple XML Array Helper  >  array2xml.php  >  Download  
File: array2xml.php
Role: Example script
Content type: text/plain
Description: Array to Xml Example
Class: Simple XML Array Helper
Generate or convert XML documents into arrays
Author: By
Last change:
Date: 2011-03-13 23:54
Size: 1,748 bytes
 

Contents

Class file image Download
<?php
require 'SimpleXMLArrayHelper.php';
$xml = new SimpleXMLArrayHelper('result', array('atr' => 2'time' => 'UTz_' time()));
$array = array(
    
'meta' => array(
        
'@generated' => 0.002,
        array(
            array(
                
'title' => array(
                    
'value' => 'Test title'
                
),
                
'keywords' => array(
                    
'value' => 'Test keywords'
                
),
                
'description' => array(
                    
'value' => 'Test description'
                
)
            )
        )
    ),
    
'collection' => array(
        array(
            array(
                
'cd' => array(
                    
'@id' => 12451,
                    array(
                        array(
                            
'artist' => array(
                                
'value' => 'Ben Harper'
                            
)
                        ),
                        array(
                            
'year' => array(
                                
'value' => 1995
                            
)
                        )
                    )
                )
            ),
            array(
                
'cd' => array(
                    
'@id' => 121,
                    array(
                        array(
                            
'artist' => array(
                                
'value' => 'Ben Harp2eer'
                            
)
                        ),
                        array(
                            
'year' => array(
                                
'value' => 1975
                            
)
                        )
                    )
                )
            )
        )
    )
);
echo 
$xml->setArray($array)->asXml();