// this is an array of arrays, with each array element representing an
// with keys ("title", "link", "description")
$items = array(),
// opening tag handler
function elementBegin($parser, $name, $attributes)
{
global $currentTag, $flag,
$currentTag = $name,
// set flag if entering
if ($name == "ITEM")
{
$flag = 1,
}
else if ($name == "CHANNEL")
{
$flag = 2,
}
}
// closing tag handler
function elementEnd($parser, $name)
{
global $currentTag, $flag, $count,
$currentTag = "",
// set flag if exiting
if ($name == "ITEM")
{
$count++,
$flag = 0,
}
else if ($name == "CHANNEL")
{
$flag = 0,
}
}
// character data handler
function characterData($parser, $data)
{
global $currentTag, $flag, $items, $count, $channel,
$data = trim(htmlspecialchars($data)),
if ($currentTag == "TITLE" || $currentTag == "LINK" ||
$currentTag ==
"DESCRIPTION")
{
// add data to $channels[] or $items[] array
if ($flag == 1)
{
$items[$count][strtolower($currentTag)] .=
$data,
}
else if ($flag == 2)
{
$channel[strtolower($currentTag)] .= $data,
}
}
}
// create parser
$xp = xml_parser_create(),
// set element handler
xml_set_element_handler($xp, "elementBegin", "elementEnd"),
xml_set_character_data_handler($xp, "characterData"),
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, TRUE),
xml_parser_set_option($xp, XML_OPTION_SKIP_WHITE, TRUE),
// read XML file
if (!($fp = fopen($file, "r")))
{
die("Could not read $file"),
}
// parse data
while ($xml = fread($fp, 4096))
{
if (!xml_parse($xp, $xml, feof($fp)))
{
die("XML parser error: " .
xml_error_string(xml_get_error_code($xp))),
}
}
// destroy parser
xml_parser_free($xp),
// now iterate through $items[] array
// and print each item as a table row
foreach ($items as $item)
{
echo "tr
"br>" . $item["description"] . "
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

Atom editor mac version download
The most popular open source editor