Jump to content
php.lv forumi

Recommended Posts

Posted (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 by oskars21
Posted (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 by 404
Posted (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 by oskars21

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...
×
×
  • Create New...