Forum Moderators: coopster
The mile long URL is:
<clickurl>http:*//someip/bin/findwhat.dll?clickthrough&y=00000&x=Xp5dW :2axf3ySKy3uFz7mSIRQGgwbfwipS6ffU6:obybDUdFcwzSPF69n5S997jnVInVupFSSqPF UwQ9VsQ5fHzodX$$Z</clickurl>
The output I get from this program is just:
http:*//someip/bin/findwhat.dll?
I was wondering how to get the program to display the entire URL. I really need the help! Thanks in advance.
Here's the program.
<?php$open_tags = array(
'RECORD' => '<RECORD>',
'TITLE' => '<TITLE>',
'DESCRIPTION' => '<DESCRIPTION>',
'CLICKURL' => '<CLICKURL>');
$close_tags = array(
'RECORD' => '</RECORD>',
'TITLE' => '</TITLE>',
'DESCRIPTION' => '</DESCRIPTION>',
'CLICKURL' => '</CLICKURL>');
?>
<?php
// handles the attributes for opening tags
// $attrs is a multidimensional array keyed by attribute
// name and having the value of that attribute
function startElement($parser, $name, $attrs=''){
global $open_tags, $temp, $current_tag;
$current_tag = $name;
if ($format = $open_tags[$name]){
switch($name){
case 'RECORD':
echo '';
break;
default:
break;
}
}
}
// $current_tag lets us know what tag we are currently
// dealing with - we use that later in the characterData
// function.
//
// when we see a </STORY> we know that it is time to
// flush our temp variables and prepare to move onto
// the next one
function endElement($parser, $name, $attrs=''){
global $close_tags, $temp, $current_tag;
if ($format = $close_tags[$name]){
switch($name){
case 'RECORD':
return_page($temp);
$temp = '';
break;
default:
break;
}
}
}
// this function is passed data between elements
// theu $data would equal 'Title Here'
// in the line <TITLE>Title Here</TITLE>
function characterData($parser, $data){
global $current_tag, $temp, $catID;
switch($current_tag){
case 'TITLE':
$temp['title'] = $data;
$current_tag = '';
break;
case 'CLICKURL':
$temp['clickurl'] .= $data;
$current_tag .= '';
break;
case 'DESCRIPTION':
$temp['description'] = $data;
$current_tag = '';
break;
default:
break;
}
}
?>
<?php
function return_page(){
global $temp;
echo '<A HREF="'.$temp['clickurl'].'">'.$temp['title'].'</A><BR>'.$temp['description'].'<p>';
}
// what are we parsing?
$xml_file = 'removed for obvious reason, sorry.';
print "$xml_file<p>";
// declare the character set - UTF-8 is the default
$type = 'ISO-8859-1';
// create our parser
$xml_parser = xml_parser_create($type);
// set some parser options
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
// this tells PHP what functions to call when it finds an element
// these funcitons also handle the element's attributes
xml_set_element_handler($xml_parser, 'startElement','endElement');
// this tells PHP what function to use on the character data
xml_set_character_data_handler($xml_parser, 'characterData');
if (!($fp = fopen($xml_file, 'r'))) {
die("Could not open $xml_file for parsing!\n");
}
// loop through the file and parse baby!
while ($data = fread($fp, 4096)) {
if (!($data = utf8_encode($data))) {
echo 'ERROR'."\n";
}
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf( "XML error: %s at line %d\n\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
?>
[edited by: jatar_k at 5:11 pm (utc) on Oct. 15, 2002]
[edit reason] disabled smileys and wrapped long string [/edit]
The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&" and "<" respectively.
[w3.org ]
Andreas