Hello i am trying to figure this out. I am super new to php and passing method of array to array php. In this code its doing every time i do something it created that xml with values. What i am trying to do it sent this to php array for later use of database. And i cant figure it out somehow.Thank you
var doc = document.implementation.createDocument(null, null, null);
var forcount=0;
var xmlarray= [], xmlcount=0;
function createxmlstruc (){
function xmlstruc() {
var node = doc.createElement(arguments[0]), text;
for(var i = 1; i < arguments.length; i++) {
if(typeof arguments[i] == 'string') {
node.appendChild(doc.createTextNode(arguments[i]));
}
else {
node.appendChild(arguments[i]);
}
}
return node;
};
var root = xmlstruc('Row',
xmlstruc('TestNum', '' +rownumbarr[forcount]),
xmlstruc('D_VALUE','' +DVALUE[forcount]),
xmlstruc('I_VALUE','' +IVALUE[forcount]),
xmlstruc('S_VALUE','' +SVALUE[forcount]),
xmlstruc('C_VALUE','' +CVALUE[forcount]),
)
xmlstruc();
console.log(root);
xmlarray[xmlcount++] = root; // in here adding xml's 1 by 1
xmlreturn(xmlarray);
forcount+=1;
}
var resulta=0;
function xmlreturn (backtoxml) {
if(resulta == 48){
$("#resultbutton").trigger('click');
}
return backtoxml;
}
i put to array whenever xml created and trying to do something with it. Is it right? and there is no answers like what i seek or solution like
and xml created like this
<Row>
<RowNum>1</RowNum>
<D_VALUE>1</D_VALUE>
<I_VALUE>3</I_VALUE>
<S_VALUE>4</S_VALUE>
<C_VALUE>2</C_VALUE>
<Row>
<RowNum> 2</RowNum>
<D_VALUE>4</D_VALUE>
<I_VALUE>1</I_VALUE>
<S_VALUE>3</S_VALUE>
<C_VALUE>2</C_VALUE>
</Row>
ok i looked again for test for using this
<?php
// function defination to convert array to xml
function array_to_xml( $data, &$xml_data ) {
foreach( $data as $key => $value ) {
if( is_numeric($key) ){
$key = 'item'.$key; //dealing with <0/>..<n/> issues
}
if( is_array($value) ) {
$subnode = $xml_data->addChild($key);
array_to_xml($value, $subnode);
} else {
$xml_data->addChild("$key",htmlspecialchars("$value"));
}
}
}
// initializing or creating array
$data = array($xmlarray);
// creating object of SimpleXMLElement
$xml_data = new SimpleXMLElement('<?xml version="1.0"?><data></data>');
// function call to convert array to xml
array_to_xml($data,$xml_data);
//saving generated xml file;
$result = $xml_data->asXML('Z:\downloads\name.xml');
?>
How to use array which contain xml's in this function which is create a xml file ? And php says undefined $xmlarray ofcourse i dont know how to use it kappa :{