Jump to content

php search many xml script


dflow

Recommended Posts

this is a bad question, we don't write scripts for others nor do we share :P therefor i shall give you the first pieces and you shall have to figure out how it will work further on

 

$xml = xml_parser_create();

$dir = "path/fo/xml/directory";

$dh = opendir($dir);

if ($dh) {

  while ($file = readdir($dh)) {

    if ($file != "." && $file != "..") {

      $path = $dir . DIRECTORY_SEPARATOR . $file;

      $data = file_get_contents($path);

      if (0 !== xml_parse($xml, $data)) {

          // i gave you the first pieces, the rest of the puzzle shall you have to figure out by yourself

      }

    }

  }

}

  • 1 month later...

would you say this is correct?

<?php

$query="SELECT * FROM Suppliers WHERE CITY='Barcelona'";

$result = mysql_query($query) or die(mysql_error());

 

 

 

$array = array();

while($row = mysql_fetch_assoc($result)) {

  $array[] = $row["XML_PATH"];

 

 

}

 

?>

<?php foreach (glob('$array[]') AS $filename) {

    $data = file_get_contents($filename);

    $sxml = simplexml_load_string($data);

    //etc etc

}?>

 

or did i mess it up?

Nah, you messed it up. >_<

 

<?php
$query="SELECT * FROM Suppliers WHERE CITY='Barcelona'";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_assoc($result)) {
  foreach (glob("{$row['XML_PATH']}/*") AS $filename) {
    $data = file_get_contents($filename);
    $sxml = simplexml_load_string($data);
    //etc etc
}


}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.