Total members 11895 |It is currently Sun Dec 22, 2024 6:38 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





php code
<?
function start_element($parser, $element_name, $element_attrs) {
switch ($element_name) {
case 'KEYWORDS':
echo '<h1>Keywords</h1><ul>';
break;
case 'KEYWORD':
echo '<li>';
break;
}
}

function end_element($parser, $element_name) {
switch ($element_name) {
case 'KEYWORDS':
echo '</ul>';
break;
case 'KEYWORD':
echo '</li>';
break;
}
}


function character_data($parser, $data) {
echo htmlentities($data);
}

$parser = xml_parser_create();
xml_set_element_handler($parser, 'start_element', 'end_element');
xml_set_character_data_handler($parser, 'character_data');

$fp = fopen('keyword-data.xml', 'r')
or die ("Cannot open keyword-data.xml!");


while ($data = fread($fp, 4096)) {
xml_parse($parser, $data, feof($fp)) or
die(sprintf('XML ERROR: %s at line %d',
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser)));
}


xml_parser_free($parser);
?>

keyword-data.xml
xml code
<!-- keyword-data.xml  -->
<keywords>
<keyword>XML</keyword>
<keyword>PHP</keyword>
<keyword>Perl</keyword>
<keyword>JavaScript</keyword>
<keyword>ASP</keyword>
</keywords>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : php SAX parser in action
 php simple XML parser     -  
 Command Line Parser Code Using C++     -  
 How to implement Command Line Parser in C++ Code     -  
 is_numeric in action     -  
 php extends in action     -  
 JButtons implementing an Action     -  
 Button action listener should implement abstract method     -  
 Two Listeners- Mutli- Action Listeners on Text Area     -  



Topic Tags

PHP XML
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com