good day ,
so here is the idea , i have a bunch of XML links and i want to merge them into one XML and convert it into CSV file, but since put it one by one in a textbox put a lot of effort, i decide to input it in a single textarea each links divided by line breaks. so if there were 10 links so it should be 10 line of links in the textarea as well
this is my code :
$str = $_POST['inp'];
$arr = explode("
", $str);
$array = array();
$cnt=0;
$ct=0;
foreach ($arr as $line) {
$array[] = $line;
$cnt++;
};
function mergeFile ( DOMDocument $target, $fileName ) {
$source = new DOMDocument();
$source->load($fileName);
foreach ( $source->getElementsByTagName("resValidateFakturPm") as $row ) {
$import = $target->importNode($row, true);
$target->documentElement->appendChild($import);
}
}
$target = new DOMDocument();
$target->loadXML('<?xml version="1.0" encoding="utf-8"?><bunch></bunch>');
for ($ct=0;$ct<count($array);$ct++){
mergeFile($target, $array[$ct]);
}
$target->save("res.xml");
but there is one tiny problem , when i put 10 of links on the textarea it didn't resulted 10 rows in the CSV files instead it only resulted 1 row ,the last one. with 9 rows before resulted blank.
where's my code fault ?