Jump to content

What's wrong with my XML parsing ?! Please Help!


shlomikalfa

Recommended Posts

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.