Sorting And Searching in XML

Discussion in 'PHP' started by 2mk_atspace, Nov 3, 2006.

  1. #1
    How to read directory structure and save it into XML document with PHP ?
    Can i sorting dan searching in XML using PHP ?
     
    2mk_atspace, Nov 3, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You're being fairly vague explaining, which makes it a bit difficult to help. Here an example though.

    
    <?php
    
    $files = glob('./path/to/files/*');
    
    header('Content-type: text/xml');
    echo '<?xml version="1.0" encoding="iso-8859-1"?>'. "\r\n";
    
    ?>
    <directory>
    	
    	<?php
    	
    	foreach ($files AS $file)
    	{
    	?>
    	
    		<item>
    			<type><?php echo (is_dir($file) ? 'Directory' : 'File'); ?></type>
    			<dir><?php echo dirname($file); ?></dir>
    			<name><?php echo basename($file); ?></name>
    		</item>
    	
    	<?php
    	}
    	?>
    	
    </directory>
    
    Code (markup):
     
    nico_swd, Nov 3, 2006 IP