PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Tiago Wust Freres   XML Access   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example PHP file of XMLAccess class
Class: XML Access
Parse and extract information from XML documents
Author: By
Last change:
Date: 15 years ago
Size: 933 bytes
 

Contents

Class file image Download
<?php
include('xmlAccess.inc');

//Loading XML file
$xml = new XMLAccess('example.xml');

//Get information at tag's attributes
echo $xml->getAttributeValueFromTagName('my-info', 'name') . '<br>';
echo
$xml->getAttributeValueFromTagName('my-info', 'email') . '<br><br>';

//Another way to get that information
$node = $xml->getNodeByTagName('my-info');
echo
$xml->getAttributeValueFromNode($node, 'name') . '<br>';
echo
$xml->getAttributeValueFromNode($node, 'email') . '<br><br>';

//Other methods
$other_node = $xml->getNodeByAttribute('tag-attr');
echo
$xml->getAttributeValueFromNode($other_node, 'tag-attr') . '<br><br>';

//Another way to find my email information
$my_node = $xml->getNodeByAttribute('name', 'Tiago Wust Freres');
echo
$xml->getAttributeValueFromNode($my_node, 'email') . '<br><br>';

//Receiving more then one result
echo '<pre>';
print_r($xml->getAttributeValueFromTagName('tag', 'attr1'));
echo
'</pre>';
?>