开发者

how to make php5 xmlParser to work on php4 server?

I'm using this xml on a php4 server

<?xml version="1.0" encoding="UTF-8" ?>
<events>
    <record>
        <event>ticket</event>
        <eventDate>09/12/2010</eventDate>
        <de开发者_JS百科sc>http://asce.co.il/page.asp?page_parent=611</desc>
    </record>
</events>

and i have this parser to be able writing on the xml file

<?php
header("Content-type: text/html; charset=utf-8");

$record = array(
    'event' => $_POST['event'],
    'eventDate' => $_POST['eventDate'],
    'desc' => $_POST['desc'],
);

$doc = new DOMDocument();
$doc->load( 'calendar.xml' );

$doc->formatOutput = true;

$r = $doc->getElementsByTagName("events")->item(0);
$b = $doc->createElement("record");

$event = $doc->createElement("event");
$event->appendChild(
    $doc->createTextNode( $record["event"] )
);
$b->appendChild( $event );

$eventDate = $doc->createElement("eventDate");
$eventDate->appendChild(
    $doc->createTextNode( $record["eventDate"] )
);
$b->appendChild( $eventDate );

$desc = $doc->createElement("desc");
$desc->appendChild(
    $doc->createTextNode( $record["desc"] )
);

$b->appendChild( $desc );
$r->insertBefore( $b,$r->firstChild );

$doc->save("calendar.xml");

header("Location: {$_SERVER['HTTP_REFERER']}");    
?>

It's all working great on a php5 server, But my problem is that my server have only php4 support

what do i need to change in the script to be able using it on my server? Thanks guys!


DOMDocument is not available for PHP4. As the php manual page suggests, use DOM XML for processing XML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜