PHP Resource
Http://www.w3schools.com/php/default.asp
<? PHP
// Initialize the XML Parser
$ Parser = xml_parser_create ();
// Function to use at the start of an element
Function start ($ parser, $ element_name, $ element_attrs)
{
Switch ($ element_name)
{
Case "NOTE ":
Echo "-- note -- <br/> ";
Break;
Case "":
Echo ":";
Break;
Case "from ":
Echo "from :";
Break;
Case "heading ":
Echo "heading :";
Break;
Case "body ":
Echo "message :";
}
}
// Function to use at the end of an element
Function stop ($ parser, $ element_name)
{
Echo "<br/> ";
}
// Function to use when finding character data
Function char ($ parser, $ data)
{
Echo $ data;
}
// Specify element Handler
Xml_set_element_handler ($ parser, "Start", "stop ");
// Specify data handler
Xml_set_character_data_handler ($ parser, "char ");
// Open XML file
$ Fp = fopen ("test. xml", "R ");
// Read data
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 )));
}
// Free the XML Parser
Xml_parser_free ($ parser );
?>