dsafew1231 2015-08-28 14:04
浏览 223

问题从PHP 5.2切换到PHP 5.3

My company has some old PHP code that has been running on PHP 5.2 for quite sometime but our web host is getting rid of PHP 5.2. The script is using domxml-php4-to-php5.php to run the domxml. For some reason when I change over to PHP 5.3 the script will not pull in the XML file. It just returns "You didn't choose a file to edit!". I just need to get this working on PHP 5.3 for the time being while I update the code for PHP 5.

<?php
session_start();
if (PHP_VERSION>='5')
require_once('domxml-php4-to-php5.php');

function extractText($array){
if(count($array) <= 1){
    //we only have one tag to process!
    for ($i = 0; $i<count($array); $i++){
        $node = $array[$i];
        $value = $node->get_content();
    }
    return $value;
} 

}   


//pull in the XML file

if ($file == ""){

echo "<h2>You didn't choose a file to edit!</h2>";
echo "<a href=\"ndpnews.php\">Go back to index and choose a file</a>";
exit;
} else {
$open = "./xml/" . $file;
$xml = domxml_open_file($open);
$root = $xml->root();

$id = $root->get_attribute("id");

$h_array = $root->get_elements_by_tagname("headline");
$headline = extractText($h_array);

$stat_array = $root->get_elements_by_tagname("status");
$status = extractText($stat_array);


$a_array = $root->get_elements_by_tagname("author");
$author = extractText($a_array);

$e_array = $root->get_elements_by_tagname("email");
$email = extractText($e_array);

$ab_array = $root->get_elements_by_tagname("abstract");
$abstract = extractText($ab_array);

$kl_array = $root->get_elements_by_tagname("keywords");
$keywords = extractText($kl_array);

$img_array = $root->get_elements_by_tagname("image");
$image = extractText($img_array);

$lead_array = $root->get_elements_by_tagname("para-intro");
$para["intro"] = extractText($lead_array);

$second_array = $root->get_elements_by_tagname("para-main");
$para["main"] = extractText($second_array);

$con_array = $root->get_elements_by_tagname("para-conclusion");
$para["con"] = extractText($con_array);

$logo_array = $root->get_elements_by_tagname("logo");
$logo = extractText($logo_array);

$dt_array = $root->get_elements_by_tagname("dateandtime");
$dateandtime = extractText($dt_array);

    $wh_array = $root->get_elements_by_tagname("where");
$where = extractText($wh_array);

$ph_array = $root->get_elements_by_tagname("phone");
$phone = extractText($ph_array);

$web_array = $root->get_elements_by_tagname("website");
$website = extractText($web_array);

$map_array = $root->get_elements_by_tagname("map");
$map = extractText($map_array);

$pagetitle_array = $root->get_elements_by_tagname("pagetitle");
$pagetitle = extractText($pagetitle_array);


?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)