Hi,
I am currently trying to parse the XML returned from the getSeries.php, but the parsing won't work as I want it to.
Currently I am getting the XML with cURL
Code:
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, "$mirrorpath/api/GetSeries.php?seriesname=$show_name");
and parse it with SAX
Code:
$parser=xml_parser_create();
xml_set_element_handler($parser, "openingTag","closingTag");
xml_set_character_data_handler($parser, "foundText");
xml_parse($parser,$xml);
xml_parser_free($parser);
function openingTag($parser,$tag,$attributes)
{
global $currentTag;
$currentTag = strtolower($tag);
}
function closingTag($parser,$tag)
{
global $currentTag;
$currentTag = null;
}
function foundText($parser,$characters)
{
global $data, $currentTag;
$data[$currentTag][] = $characters;
}
But when I want to echo the results I always get mistakes when it comes to & and '.
When there is a
& in the title it is seen as a new show and
' is changed to some other symbols
and also lets the parser think it is a new show.
Code:
echo "<table>";
for($count=0; $count < count($data["seriesid"]); $count++)
{
echo "<tr>";
echo "<td>" . $data["seriesname"][$count] . "</td>";
echo "<td class='input'>" . $data["seriesid"][$count] . "</td>";
echo "</tr>";
echo "<tr>";
}
echo "</table>";
Does anyone have a solution for this problem?
Like letting the parser completely ignore what is between the tags.
I tried replacing & with "and", but this doesn't really solve the problem for other characters.
Thanks in advance
whw