XML解析器:迭代数组时的无效参数

时间:2015-04-12 23:21:56

标签: php arrays

我已经查看迭代数组的examples,但是在我这样做的时候会收到以下错误:

  

警告:为foreach()提供的参数无效   /home/cdlwebde/public_html/sofia_nikolsky911/Project/includes/load.php   在第33行。

这是我正在尝试执行的代码:

// Convert the data string into two arrays.  The array $xml_contents will contain each 
// element in the XML file.  The array $tag_index will be an associative array organized
// by tag names with a list of the indexes where that tag occurs.
xml_parse_into_struct($parser, $data, $xml_contents, $index);

// Pull out the index array for just the object tag specified as a parameter to this
// function. This array will have the index for just the elements in the XML file with  
// the specified object tag.
$xml_object_index_array = $index[$xml_object_tag];  //$xml_object_tag is a string

// Loop through all the instances of that object tag, looking for each start tag. 
foreach ($xml_object_index_array as $occurrence=>$tag_index) 
{
    // do whatever
} 

0 个答案:

没有答案