oskars21 Posted April 12, 2012 Report Share Posted April 12, 2012 (edited) scriptam bus no xml failiniem jasavac info, bet neiznu ka dabut konkreto elementu. piemeram "tiitle" šis ir tikai testam pagaidam tapec netiesājiem mani parak bargi es vel macos:D <?php $dir = "kkas"; $masa = glob($dir . "*", GLOB_ONLYDIR); $fileNamePrefix = "METS-" ; $fileNameSuffix = ".xml" ; $folderNamePattern = "/[0-9]{5,9}/" ; foreach ($masa as $FileNamePath) { if (false && empty($first_run)) { continue; $first_run = 1; } $fileName = basename($FileNamePath); if (! preg_match ( $folderNamePattern, $fileName) ) { continue; } $fileNameFullPath = $FileNamePath . "/" . $fileNamePrefix . $fileName . $fileNameSuffix; if (! @file_exists ($fileNameFullPath) || !@is_readable ( $fileNameFullPath) ) { continue; } $xml = file_get_contents($fileNameFullPath); $xml = preg_replace('~(</?|\s)([a-z0-9_]+):~is', '$1$2_', $xml); $tittle= new SimpleXMLElement($xml); var_dump($tittle??????????); } ?> <?xml version="1.0" encoding="UTF-8"?> <mets:mets xmlns:mets="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.loc.gov/METS/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/mets.xsd"> <mets:metsHdr CREATEDATE="2008-11-24T11:31:50"> <mets:agent ROLE="DISSEMINATOR" TYPE="INDIVIDUAL"> <mets:name>blla</mets:name> </mets:agent> <mets:agent ROLE="CREATOR" TYPE="INDIVIDUAL"> <mets:name>blale</mets:name> </mets:agent> </mets:metsHdr> <mets:dmdSec ID="DMD819208" CREATED="2008-11-24T11:31:50" STATUS="current"> <mets:mdWrap MDTYPE="DC"> <mets:xmlData> <dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:title>kkkas</dc:title> Edited April 12, 2012 by oskars21 Quote Link to comment Share on other sites More sharing options...
404 Posted April 12, 2012 Report Share Posted April 12, 2012 (edited) Šis: $xml = file_get_contents($fileNameFullPath); $xml = preg_replace('~(</?|s)([a-z0-9_]+):~is', '$1$2_', $xml); ir pats neefektīvākais veids kā apstrādāt XML. Izmantojot SimpleXML,tas darās šādi Edited April 12, 2012 by 404 Quote Link to comment Share on other sites More sharing options...
oskars21 Posted April 12, 2012 Author Report Share Posted April 12, 2012 (edited) pagaidam citus nezinu bet pec ta turtoriala sanak kkkas shads var_dump($tittle->mets_mets->mets_metsHdr->mets_agent->mets_name); bet met erroru ara Trying to get property of non-object Edited April 12, 2012 by oskars21 Quote Link to comment Share on other sites More sharing options...
oskars21 Posted April 12, 2012 Author Report Share Posted April 12, 2012 nomemu mets_mets dats paradijas, diezgan liela mistika pagaidam ar to visu, un tie celi citiem kilometriem gari :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.