shlomikalfa Posted November 2, 2010 Share Posted November 2, 2010 Hi, My XML OUTPUT: http://pastebin.com/gYf2h264 My PHP code: receiving the entire content of the above output as a string. ($XMLData) function readDatabase($XMLData){ // read the XML database of aminoacids $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); xml_parse_into_struct($parser, $XMLData, $values, $tags); xml_parser_free($parser); // response array $response = '<?xml version="1.0"?> <response>'; // loop through the structures foreach ($tags as $key=>$val) { if ($key!="addedit" and $key!="delete" and $key!="categories"){continue;} $opvars = $val; // each contiguous pair of array entries are the // lower and upper range for each molecule definition for ($i=0; $i < count($opvars); $i+=2) { $offset = $opvars[$i] + 1; $len = $opvars[$i + 1] - $offset; $taskvals = array_slice($values, $offset, $len); $sID = -1;$id = -1;$task = array();$perma = ""; for ($i2=0; $i2 < count($taskvals); $i2++) { $tval = stripslashes($taskvals[$i2]["value"]); if ($taskvals[$i2]["tag"]=="sID"){$sID = $tval; continue;} if ($taskvals[$i2]["tag"]=="post_category"){ $vals = explode(",", $tval); $tval = array(); foreach ($vals as $val){ $id = get_cat_ID($val); if ($id==0){ $toxo = wp_insert_term( $val, "category"); $tval[] = $toxo["term_id"]; }else{ $tval[] = $id; } } } $task[$taskvals[$i2]["tag"]] = $tval; } ......... Irrelevant..... for some reason it seems like the "post_content" is cut half-way... why ??? how do I fix it?!? Thanks in advance, Have a nice day. SK. Link to comment https://forums.phpfreaks.com/topic/217513-whats-wrong-with-my-xml-parsing-please-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.