Jump to content
php.lv forumi

xml


oskars21
 Share

Recommended Posts

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 by oskars21
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...