我只想说明为什么不在我的服务器上工作。
我希望有人会帮助我: 我将尽量明确这一点。
我在PHP+XML+DOM中做了很好的工作说明,书写为xml,用Xml阅读器显示。 并且为某些免费接待工作提供了良好效果
now..I copy the files into my server and it s not working. I can see the xml with the reader.. but i can t write on the xml file.
www.un.org/Depts/DGACM/index_spanish.htm 这些是这两个地方相同的档案。
Can you help me please?
www.un.org/Depts/DGACM/index_spanish.htm BTW:Feel Free to Add any data to the xml.it s only for the example.
<>Sites:
My Server: http://apps.sce.ac.il/testxml/asce/xml/XmlReader.php
<>pInfo>:
Free Hosting: http://ofear.onlinewebshop.net/xml/phpinfo.php
我的服务器:http://apps.sce.ac.il/testxml/asce/xml/phpinfo.php
<<>Files:
events.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<events>
<record>
<event>1</event>
<eventDate>2</eventDate>
<desc>3</desc>
</record>
</events>
<<>strong>parser.php:(我为脱胎添加了对应内容)<>。
<?php
header("Content-type: text/html; charset=utf-8");
echo("set header<br/>");
$record = array(
event => $_POST[ event ],
eventDate => $_POST[ eventDate ],
desc => $_POST[ desc ],
);
echo("set array<br/>");
$doc = new DOMDocument();
$doc->load( events.xml );
echo("make new dom and load the xml<br/>");
$doc->formatOutput = true;
echo("formatin output<br/>");
$r = $doc->getElementsByTagName("events")->item(0);
echo("get element events<br/>");
$b = $doc->createElement("record");
echo("create element record<br/>");
$event = $doc->createElement("event");
echo("create element event<br/>");
$event->appendChild(
$doc->createTextNode( $record["event"] )
);
echo("create TextNode event<br/>");
$b->appendChild( $event );
echo("appendChild event<br/>");
$eventDate = $doc->createElement("eventDate");
$eventDate->appendChild(
$doc->createTextNode( $record["eventDate"] )
);
echo("create TextNode eventDate<br/>");
$b->appendChild( $eventDate );
echo("appendChild eventDate<br/>");
$desc = $doc->createElement("desc");
$desc->appendChild(
$doc->createTextNode( $record["desc"] )
);
echo("create TextNode desc<br/>");
$b->appendChild( $desc );
echo("appendChild desc<br/>");
$r->insertBefore( $b,$r->firstChild );
echo("insertBefore firstChild<br/>");
$doc->save("events.xml");
echo("Saving events.xml<br/>");
echo("<br/><br/><a href= XmlReader.php >Go Back to XML Reader</a><br/>");
// header("Location: {$_SERVER[ HTTP_REFERER ]}");
?>
<XmlReader.php:(只有php script)
<?php
$doc = new DOMDocument();
$doc->load( events.xml );
$events = $doc->getElementsByTagName( "record" );
foreach( $events as $record )
{
$events = $record->getElementsByTagName( "event" );
$event = $events->item(0)->nodeValue;
$eventDates= $record->getElementsByTagName( "eventDate" );
$eventDate= $eventDates->item(0)->nodeValue;
$descs = $record->getElementsByTagName( "desc" );
$desc = $descs->item(0)->nodeValue;
echo "<tr><td>$event</td><td>$eventDate</td><td>$desc</td></tr>";
}
?>