Hi guys I need some help I have a xml document with the following info
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user><name>Skuilnaam</name><score>8</score></user><user><name>Skuilnaam1</name><score>10</score></user><user><name>cobus</name><score>5</score></user></users>
and a php script to dump rows in a table with coding to remove the info in the xml document but I cant seem to get it to work it just shows me the rows but dont delete them
<?
$db_host = "xxxxxxxxxxx";
$db_user = "xxxxxxxxxxxx";
$db_pass = "xxxxxxxxxxxxxx";
$db_name = "xxxxxxxxxxx";
$connect = @mysql_connect($db_host,$db_user,$db_pass);
@mysql_select_db($db_name);
static $leaderboardfile = 'res/leaders.xml';
// Empty table
$query = "TRUNCATE TABLE rente";
mysql_query($query);
?>
<?php
$retriever = new DOMDocument();
$retriever ->load( 'res/leaders.xml' );
$masterElement = $retriever->documentElement;
$masterContent = $masterElement->getElementsByTagName('user')->item(0);
$oldContent = $masterElement->removeChild($masterContent );
echo $retriever->saveXML();
?>
can someone help me to get my php document correct so it can clean my xml document to just show the xml doc with the following info in it afterwards
<?xml version="1.0" encoding="UTF-8"?>
<users>
<</users>
Added after 21 minutes:
cobusbo wrote: Hi guys I need some help I have a xml document with the following info
<?xml version="1.0" encoding="UTF-8"?> <users> <user><name>Skuilnaam</name><score>8</score></user><user><name>Skuilnaam1</name><score>10</score></user><user><name>cobus</name><score>5</score></user></users>and a php script to dump rows in a table with coding to remove the info in the xml document but I cant seem to get it to work it just shows me the rows but dont delete them
<? $db_host = "xxxxxxxxxxx"; $db_user = "xxxxxxxxxxxx"; $db_pass = "xxxxxxxxxxxxxx"; $db_name = "xxxxxxxxxxx"; $connect = @mysql_connect($db_host,$db_user,$db_pass); @mysql_select_db($db_name); static $leaderboardfile = 'res/leaders.xml'; // Empty table $query = "TRUNCATE TABLE rente"; mysql_query($query); ?> <?php $retriever = new DOMDocument(); $retriever ->load( 'res/leaders.xml' ); $masterElement = $retriever->documentElement; $masterContent = $masterElement->getElementsByTagName('user')->item(0); $oldContent = $masterElement->removeChild($masterContent ); echo $retriever->saveXML(); ?>can someone help me to get my php document correct so it can clean my xml document to just show the xml doc with the following info in it afterwards
<?xml version="1.0" encoding="UTF-8"?> <users> <</users>
ok I manage to get it to work but now I got some other help needed
<?php
$retriever = new DOMDocument();
$retriever ->load( 'res/leaders.xml' );
$masterElement = $retriever->documentElement;
$masterContent = $masterElement->getElementsByTagName('user')->item(0);
$oldContent = $masterElement->removeChild($masterContent );
echo $retriever->saveXML();
echo $retriever->save( 'res/leaders.xml' );
?>
This delete each record as I refresh it each time, isnt there a way to delete all at once or create a table where I can tick off to delete each record? and after I deleted all the records isn't there a way to tell me there are no more records and link me back to the index? in place of getting the error
Catchable fatal error: Argument 1 passed to DOMNode::removeChild() must be an instance of DOMNode, null given in /srv/disk1/1296487/www/rekvasvra.uni.me/Gr10/Rente/cron.php on line 23 when all records are deleted
