Hi All, I have a use case scenario in which I have to only harvest a specific item. I came across this post from SO: Harvesting single items with DSpace <http://stackoverflow.com/q/33346023/1919069>. His solution worked when I tried it, but in my case, I would like to have the bitstream included in the created ZIP file. Also, instead of using the default oai_dc metadataPrefix, I would like to use dim. Below is his solution in php code. Hope someone can point me how to modify his code to meet my requirements.
<?php // handle and harvest-string $handle = "1874/1506"; $harvest = "http://dspace.library.uu.nl/oai/request?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:dspace.library.uu.nl:" . $handle; // get XML from source repository $sxe = simplexml_load_file($harvest, "SimpleXMLElement"); // add namespace schema-urls $sxe->registerXPathNamespace('oai_dc', 'http://www.openarchives.org/OAI/2.0/oai_dc/'); $sxe->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/'); // get Dublin Core (dc) elements from the XML foreach($sxe->xpath("//oai_dc:dc") as $entry) { $child = $entry->children('dc', true); } // add dc-elements (names and values) to array foreach($child as $elementName => $elementValue) {$elements[$elementName][] = $elementValue;} // create zip-object and -file $zip = new ZipArchive(); $zip->open("doc/importZip.zip", ZipArchive::CREATE); // create a directory in the zip-object $zip->addEmptyDir("item"); // create Dublin Core XML object $oXML = new DOMDocument(); $oXML->encoding = "UTF-8"; $oXML->formatOutput = true; $oXML->xmlStandalone = false; $oRoot = $oXML->createElement('dublin_core'); $oRoot->setAttribute('schema', 'dc'); $oXML->appendChild($oRoot); // add elements and their values to XML object foreach($elements as $elementName => $elementValues) { foreach($elementValues as $elementValue) { $oDcValue = $oXML->createElement('dcvalue'); $oDcValue->setAttribute('element', $elementName); $oText = $oXML->createTextNode($elementValue); $oDcValue->appendChild($oText); $oRoot->appendChild($oDcValue); } } // save created XML to string $dublinCoreXml = $oXML->saveXML(); // add XML-string as file to zip-object $zip->addFromString("item/1/dublin_core.xml", $dublinCoreXml); // add handle as file to zip-object $zip->addFromString("item/1/handle", $handle); $zip->close(); ?> Thanks in advance, euler -- You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group. To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech+unsubscr...@googlegroups.com. To post to this group, send email to dspace-tech@googlegroups.com. Visit this group at https://groups.google.com/group/dspace-tech. For more options, visit https://groups.google.com/d/optout.