jenni_fur Posted April 20, 2006 Share Posted April 20, 2006 hey, i actually have a number of problem with a project i'm working on but at the moment this is the most frustrating. Two problems, firstly if I input over 1000 charasters to my xml file, in any particular field, it crashes! and secondly when i use anything like <>/""'' it crashes too! my attempt at using CDATA! scritp thus far has been unsuccessful and i woud be greatful for some input....! this is the parser [!--sizeo:1--][span style=\"font-size:8pt;line-height:100%\"][!--/sizeo--][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]EDIT-Zanus: Put code, especially long code into the code tagto make it easier for people to read please[!--colorc--][/span][!--/colorc--][!--sizec--][/span][!--/sizec--][code]<?phpif( ! ($fp = fopen( "./home.xml" , "r" )) ) die("Couldn't open xml file!");$person_counter_home = 0;$person_data_home = array();$xml_current_tag_state_home = '';function startElementHandlerHome( $parser_home, $element_name_home, $element_attribs_home ){ global $person_counter_home; global $person_data_home; global $xml_current_tag_state_home; if( $element_name_home == "STORY" ) { // $person_data_home[$person_counter_home]["author"] = $element_attribs_home["AUTHOR"]; } else { $xml_current_tag_state_home = $element_name_home; }}function endElementHandlerHome( $parser_home, $element_name_home ){ global $person_counter_home; global $person_data_home; global $xml_current_tag_state_home; $xml_current_tag_state_home = ''; if( $element_name_home == "STORY" ) { $person_counter_home++; }}function characterDataHandlerHome( $parser_home , $data_home ){ global $person_counter_home; global $person_data_home; global $xml_current_tag_state_home; if( $xml_current_tag_state_home == '' ) return;if( $xml_current_tag_state_home == "HOMEPAGE" ) { $person_data_home[$person_counter_home]["homepage"] = $data_home; } if( $xml_current_tag_state_home == "WELCOME" ) { $person_data_home[$person_counter_home]["welcome"] = $data_home; } if( $xml_current_tag_state_home == "MAIN" ) { $person_data_home[$person_counter_home]["main"] = $data_home; } if( $xml_current_tag_state_home == "NEWINFO" ) { $person_data_home[$person_counter_home]["newinfo"] = $data_home; } if( $xml_current_tag_state_home == "IMAGE" ) { $person_data_home[$person_counter_home]["image"] = $data_home; } if( $xml_current_tag_state_home == "ALT" ) { $person_data_home[$person_counter_home]["alt"] = $data_home; } }if( !($xml_parser_home = xml_parser_create()) ) die("Couldn't create XML parser!");xml_set_element_handler($xml_parser_home, "startElementHandlerHome", "endElementHandlerHome");xml_set_character_data_handler($xml_parser_home, "characterDataHandlerHome");while( $data_home = fread($fp, 4096) ){ if( !xml_parse($xml_parser_home, $data_home, feof($fp)) ) { break; // get out of while loop if we're done with the file }}xml_parser_free($xml_parser_home);?> <?php $article = $homepageContent; $thisPos_home = -1; $lengthOfArrayHome = count($person_data_home); for( $i=0; $i < $lengthOfArrayHome; ++$i ) { $thisName_home = $person_data_home[$i]["homepage"]; //echo $thisName_home. "<br>";if ($thisName_home == $article) { $thisPos_home = $i; } } //unset($person_data_home[$thisPos_home]); $elementPos_home = 0; if ($thisPos_home==-1) { $elementPos_home = $lengthOfArrayHome; } else { $elementPos_home = $thisPos_home; } ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7937-parsing-problem/ Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 What do you mean my "crash"?Ken Quote Link to comment https://forums.phpfreaks.com/topic/7937-parsing-problem/#findComment-28987 Share on other sites More sharing options...
jenni_fur Posted April 20, 2006 Author Share Posted April 20, 2006 yeah, i dont think i explained myself very well. Sorryi have built a content management system to edit and update a site i'm working on, however if i input over 1000 characters into any particular field, it will only display the amout of characters in excess of the 1000 character limit. At first i thought this was a simple html css problem, however on closer inspection, when i upload new info to the xmi via my content management system, it does actually work, however once i view it on the public site, only the excess characters show.would it help if i posted the code that is supposed to print the content from the XML?? this is it below[code]<?phpinclude "./homeparser.inc"; ?> <?php include "./homearray.inc";?><div id="home"> <?phpecho "<h1>"; for( $i=0; $i < $lengthOfArrayHome; ++$i ) { $thisNameHome = $person_data_home[$i]["welcome"]; echo $welcomeContent=$thisNameHome."<br>";}echo "<br>";echo "whats new..";echo "</h1>";?> <?phpecho "<h4>"; for( $i=0; $i < $lengthOfArrayHome; ++$i ) { $thisNameHome = $person_data_home[$i]["newinfo"]; echo $newinfoContent=$thisNameHome."<br>";}echo "</h4>";?><?phpecho "<h2>";for( $i=0; $i < $lengthOfArrayHome; ++$i ) { $thisNameHome = $person_data_home[$i]["main"]; echo $mainContent=$thisNameHome."<br>";}echo "</h2>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7937-parsing-problem/#findComment-29006 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.