File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/parse_with_simplexml.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/glomodul/z_examples/book_video/03steinmetz_2008/parse_with_simplexml.php  >  Download  
File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/parse_with_simplexml.php
Role: Example script
Content type: text/plain
Description: Example script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change:
Date: 1 month ago
Size: 509 bytes
 

Contents

Class file image Download
<?php
// You can use simplexml_load_file() to create the object
//from a file instead of using this two-step process:
$xs = file_get_contents("sins.xml");
$data = new SimpleXMLElement($xs);
echo
'<pre>'; print_r($data); echo '</pre>';
//
print 'First sin: '. $data->sins->sin[0] . ', Tip : '.$data->sins->sin[0]["type"];
print
'<br/>Tip drugog elem.: '.$data->sins->sin[1]["type"];

echo
'<br/><br/>';
foreach (
$data->sins->sin as $sin) {
    print
$sin . " : " . $sin["type"];
    print
"<br />";
}

?>

For more information send a message to info at phpclasses dot org.