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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| public function updateXMLFile() {
// create doctype
echo 199999;
$doc = new DOMDocument("1.0","UTF-8");
$doc->load('/home/tft/greenstone/collect/viprivattest/import/comm/metadata.xml');
//-----------------------------------------------------------------------------------------------------------------------------
// Create a Child Element FileSet under DirectoryMetadata
$FileSet=$doc->createElement("FileSet");
$doc->documentElement->appendChild($FileSet);
// Create a Child Element Texte Node ( "") for FileSet
$FileSetText=$doc->createTextNode("");
$FileSet->appendChild($FileSetText);
//-----------------------------------------------------------------------------------------------------------------------------
// Create a Child Element -> Child Element FileName
$FileName=$doc->createElement("FileName");
$FileSet->appendChild($FileName);
// Create a Child Element Texte Node
$FileNameText=$doc->createTextNode($this->name);//
$FileName->appendChild($FileNameText);
//-----------------------------------------------------------------------------------------------------------------------------
// Create a Child Element -> Child Element Description
$Description=$doc->createElement("Description");
$FileSet->appendChild($Description);
// Create a Child Element Texte Node
$DescriptionText=$doc->createTextNode("");
$Description->appendChild($DescriptionText);
//-----------------------------------------------------------------------------------------------------------------------------
//for ($i=0;$i<count($this->content);$i++) {
foreach ($this->meta as $key => $value) {
// Create a Child Element -> Child Element-> Child Element
$Metadata[$key]=$doc->createElement("Metadata");
$Description->appendChild($Metadata[$key]);
// Create a Child Element Texte Node
$MetadataText[$key]=$doc->createTextNode($value);
$Metadata[$key]->appendChild($MetadataText[$key]);
// create attribute node 1
$mode = $doc->createAttribute("mode");
$Metadata[$key]->appendChild($mode);
// create attribute value node
$modeValue = $doc->createTextNode("accumulate");
$mode->appendChild($modeValue);
// create attribute node 2
$name = $doc->createAttribute("name");
$Metadata[$key]->appendChild($name);
// create attribute value node
$nameValue = $doc->createTextNode("vi.".$key);
$name->appendChild($nameValue);
}
//-----------------------------------------------------------------------------------------------------------------------------
//echo $doc->saveXML();
$order = $doc->save("Met.xml"); |
Partager