тестовый кусок кода

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
function XML_Add_New_Fig($a,$b,$c,$d)
{
$dom = new DomDocument();
$dom->load("content.xml");
$workflowElements = $dom->getElementsByTagName("root");
$root = $workflowElements->item(0);
$element = $dom->createElement('fig');
$root->appendChild($element);
$root_child = $root->getElementsByTagName("fig");
$dom->save("content.xml");
XML_Add_Atribute_ID(($d-1),"cat_id", $a);
XML_Add_Atribute_ID(($d-1),"descript", $b);
XML_Add_Atribute_ID(($d-1),"main_pic", $c);
}
function XML_Add_Atribute_ID($id, $atr, $data) {
$doc = new DomDocument();
$doc->load("content.xml");
$workflowElements = $doc->getElementsByTagName("root");
$root = $workflowElements->item(0);
$statistics = $root->getElementsByTagName("fig")->item($id);
//$total = $statistics->getAttribute("cat_id");
$statistics->setAttribute($atr, $data);
$doc->save("content.xml");
}
//if(($_POST ["catid"])<>"")
//{
//XML_Add_Atribute_ID(1,"cat_id",($_POST ["catid"]));
//XML_Add_Atribute_ID(1,"descript",($_POST ["name"]));
//XML_Add_Atribute_ID(1,"main_pic",($_POST ["pic"]));
//}
?>