本文整理汇总了PHP中XMLReader::readOuterXML方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLReader::readOuterXML方法的具体用法?PHP XMLReader::readOuterXML怎么用?PHP XMLReader::readOuterXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLReader
的用法示例。
在下文中一共展示了XMLReader::readOuterXML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start_process
public function start_process()
{
if (!$this->path_to_xml_file) {
return false;
}
if (!$this->valid_xml) {
return false;
}
$this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => DOC_ROOT . 'temp/xml_to_archive/'));
$this->taxon_ids = array();
$this->media_ids = array();
$this->vernacular_name_ids = array();
$this->reference_ids = array();
$this->agent_ids = array();
$reader = new \XMLReader();
$file = file_get_contents($this->path_to_xml_file);
$file = iconv("UTF-8", "UTF-8//IGNORE", $file);
$reader->XML($file);
$i = 0;
while (@$reader->read()) {
if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "taxon") {
$taxon_xml = $reader->readOuterXML();
$t = simplexml_load_string($taxon_xml, null, LIBXML_NOCDATA);
if ($t) {
$this->add_taxon_to_archive($t);
}
$i++;
if ($i % 100 == 0) {
echo "Parsed taxon {$i} : " . time_elapsed() . "\n";
}
// if($i >= 5000) break;
}
}
$this->archive_builder->finalize();
}
示例2: scan
/**
* @throws RuntimeException
* @return array of arrays.
* array( 'dumpKey' => array( 'match1', 'match2' ) )
*/
public function scan()
{
$openSuccess = $this->reader->open($this->dumpLocation);
if (!$openSuccess) {
throw new RuntimeException('Failed to open XML: ' . $this->dumpLocation);
}
$result = array();
foreach ($this->query as $queryKey => $query) {
$result[$queryKey] = array();
// Make sure keys are returned even if empty
}
while ($this->reader->read() && $this->reader->name !== 'page') {
}
while ($this->reader->name === 'page') {
$element = new SimpleXMLElement($this->reader->readOuterXML());
$page = $this->getPageFromElement($element);
foreach ($this->query as $queryKey => $query) {
$match = $this->matchPage($page, $query);
if ($match) {
//TODO allow the user to choose what to return
$result[$queryKey][] = $page->getTitle()->getTitle();
}
}
$this->reader->next('page');
}
$this->reader->close();
return $result;
}
示例3: main
function main()
{
var_dump(stream_wrapper_register('strstream', 'StringWrapper'));
$r = new XMLReader();
$r->open("strstream://");
var_dump($r->read());
var_dump($r->readOuterXML());
var_dump($r->readInnerXML());
var_dump($r->read());
var_dump($r->readOuterXML());
var_dump($r->readInnerXML());
}
示例4: eol_xml_stats
function eol_xml_stats()
{
$path = "http://localhost/eol_php_code/applications/content_server/resources/218.xml";
$reader = new \XMLReader();
$reader->open($path);
$i = 0;
$dist_count = 0;
$taxa_count = 0;
while (@$reader->read()) {
if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "taxon") {
$string = $reader->readOuterXML();
$string = str_ireplace("dc:", "dc_", $string);
$string = str_ireplace("dwc:", "dwc_", $string);
if ($xml = simplexml_load_string($string)) {
$taxa_with_dist = false;
$taxon_id = (string) $xml->dc_identifier;
print "[{$taxon_id}]";
foreach ($xml->dataObject as $o) {
if (@$o->subject == "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Distribution") {
$dist_count++;
$taxa_with_dist = true;
}
}
if ($taxa_with_dist) {
$taxa_count++;
}
}
}
}
print "\n\n";
print "\n distribution: [{$dist_count}]";
print "\n taxa with dist: [" . $taxa_count . "]";
print "\n\n";
}
示例5: filterFeed
/**
* filterFeed Reads the XML from the url and filters it based on the provided filter. The results are organized into an array keyed by the unqiue values of the filter.
*/
function filterFeed()
{
$reader = new XMLReader();
if (!$reader->open($this->url)) {
throw new Exception("Cannot open feed from the provided URL.");
}
while ($reader->read()) {
if ($reader->name == "product") {
//get the entire product node.
$xml_node = $reader->readOuterXML();
}
if ($reader->name == $this->filter) {
//read the values for the $this->filter node.
$reader->read();
//get string/value from the node we are filtering and explode it by a delimiter.
$nodeValues = [];
$nodeValues = explode($this->delimiter, $reader->value);
if (!empty($nodeValues[$this->index])) {
$this->filteredXML[$nodeValues[$this->index]][] = $xml_node;
} else {
throw new Exception("The index specified does not exist.");
}
//Go to the next product.
$reader->next("product");
}
}
//if the array has no items then the filtered node does not exist.
if (empty($this->filteredXML)) {
throw new Exception("{$this->filter} does not exist in the XML.");
}
}
示例6: get_all_taxa
public function get_all_taxa()
{
if (!file_exists(DOC_ROOT . 'tmp/natureserve')) {
mkdir(DOC_ROOT . 'tmp/natureserve');
}
if (!file_exists(DOC_ROOT . 'tmp/natureserve/images')) {
mkdir(DOC_ROOT . 'tmp/natureserve/images');
}
$this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => DOC_ROOT . "/temp/dwc_archive_test/"));
$species_list_path = DOC_ROOT . "update_resources/connectors/files/natureserve_species_list.xml";
shell_exec("rm -f {$species_list_path}");
shell_exec("curl " . self::SPECIES_LIST_URL . " -o {$species_list_path}");
$reader = new \XMLReader();
$reader->open($species_list_path);
$records = array();
while (@$reader->read()) {
if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "DATA_RECORD") {
$record = simplexml_load_string($reader->readOuterXML(), null, LIBXML_NOCDATA);
$records[] = (string) $record->EGT_UID;
}
}
echo "Total Records: " . count($records) . "\n";
$chunk_size = 1;
// shuffle($records);
// array_unshift($records, 'ELEMENT_GLOBAL.2.104470'); // Bald eagle
array_unshift($records, 'ELEMENT_GLOBAL.2.102211');
// Polar bear
// array_unshift($records, 'ELEMENT_GLOBAL.2.106470'); // bobcat - Lynx rufus
// array_unshift($records, 'ELEMENT_GLOBAL.2.104731'); // striped bass - Morone saxatilis
array_unshift($records, 'ELEMENT_GLOBAL.2.105926');
// American Bullfrog
array_unshift($records, 'ELEMENT_GLOBAL.2.104777');
// White tailed deer
array_unshift($records, 'ELEMENT_GLOBAL.2.100925');
// golden eagle
$records = array_unique($records);
$chunks = array_chunk($records, $chunk_size);
$i = 0;
$start_time = time_elapsed();
foreach ($chunks as $chunk) {
$this->lookup_multiple_ids($chunk);
// if($i % 500 == 0) print_r($this->archive_builder->file_columns);
$i += $chunk_size;
if ($i % 100 == 0) {
$estimated_total_time = (time_elapsed() - $start_time) / $i * count($records);
echo "Time spent ({$i} records) " . time_elapsed() . "\n";
echo "Estimated total seconds : {$estimated_total_time}\n";
echo "Estimated total hours : " . $estimated_total_time / (60 * 60) . "\n";
echo "Memory : " . memory_get_usage() . "\n";
}
// if($i >= 100) break;
}
$this->archive_builder->finalize();
}
示例7: insert_data_mysql
private function insert_data_mysql($db)
{
$tbl = $db->query("select sigla, nome from estados");
$db->query("SET CHARACTER SET utf8");
$db->query("SET NAMES utf8");
$tbl->setFetchMode(PDO::FETCH_OBJ);
while ($row = $tbl->fetch()) {
// MySQL
$arr_estados[mb_strtoupper(iconv("ISO-8859-1", "UTF-8", $row->nome), "UTF-8")] = $row->sigla;
// PostgreSQL
// $arr_estados[mb_strtoupper($row->nome, "UTF-8")] = $row->sigla;
}
var_dump($arr_estados);
$xml = new XMLReader();
$xml->open('database/seeds/BR Localidades 2010 v1.kml');
// Salta as informações de cabeçalho, para o primeiro "registro" de dados ("Placemark")
while ($xml->read() && $xml->name !== "Placemark") {
}
$contador = 0;
$insert_ok = 0;
$insert_erro = 0;
$sql = $db->prepare("insert into cidades(codigo, nome, sigla_estado, longitude, latitude, altitude) values(?, ?, ?, ?, ?, ?)");
// Loop para varrer todas as ocorrências de "Placemark"
while ($xml->name === "Placemark") {
$node = new SimpleXMLElement($xml->readOuterXML());
$cidade = new SimpleXMLElement($node->asXML());
$nome = strval($cidade->name);
// $nome = str_replace("'", "''", $nome);
$sdata = $cidade->ExtendedData->SchemaData->SimpleData;
$codigo = intval($sdata[9]);
$sigla_estado = $arr_estados[strval($sdata[13])];
$longitude = floatval($sdata[18]);
$latitude = floatval($sdata[19]);
$altitude = floatval($sdata[20]);
$res = $sql->execute(array($codigo, $nome, $sigla_estado, $longitude, $latitude, $altitude));
if ($res) {
$insert_ok++;
} else {
$insert_erro++;
echo $nome . " " . $codigo . " " . $sigla_estado . " " . $longitude . " " . $latitude . " " . $altitude . "<br>";
}
// Salta para próximo registro
$xml->next("Placemark");
}
echo "Incluiu {$insert_ok} registros com sucesso<br>";
echo "Falha na inclusão de {$insert_erro} registros<br>";
}
示例8: while
function get_all_taxa($data_dump_url = false)
{
/* working but commented during development...
if(!$data_dump_url) $data_dump_url = $this->data_dump_url;
$path = self::download_and_extract_remote_file($data_dump_url);
echo "\n xml file: [$path] \n";
*/
$path = "http://localhost/~eolit/xml_parser/bioproject.xml";
// debug
$reader = new \XMLReader();
$reader->open($path);
$i = 0;
while (@$reader->read()) {
if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "Package") {
$string = $reader->readOuterXML();
if ($xml = simplexml_load_string($string)) {
$i++;
self::parse_record_element($xml);
// echo("\n $i. ");
// print_r($xml);
if ($i > 20) {
break;
}
}
// // debug - to process by batch
// $i++;
// if($i > 10)
// {
// // self::parse_record_element($xml);
// print_r($xml);
// if($i > 20) break;
// }
}
}
$supergroups = array_keys($this->stats["supergroup"]);
print "\n";
print "\n unique taxon_ids: " . count($this->taxon_ids);
print "\n";
print_r($supergroups);
foreach ($supergroups as $supergroup) {
print "\n[{$supergroup}] " . count(array_keys($this->stats["supergroup"][$supergroup]));
//print_r(array_keys($this->stats["supergroup"][$supergroup]));
}
print "\n\n";
$this->create_archive();
unlink($path);
}
示例9: XMLReader
<?php
$xml = <<<EOF
<a>
<b>0</b>
<c>1<d>2<e>3</e>4</d>5</c>
</a>
EOF;
$reader = new XMLReader();
$reader->XML($xml);
while ($reader->read()) {
var_dump($reader->readOuterXML());
}
示例10: odt2html
//.........这里部分代码省略.........
break;
}
//We can't handle that at the moment
while ($xml->read() && ($xml->name != "style:style" || $xml->nodeType != XMLReader::END_ELEMENT)) {
if ($xml->name == "style:text-properties") {
if ($xml->getAttribute("fo:font-style") == "italic") {
$styles[$name]["tags"][] = "em";
}
//Creates the style and add <em> to its tags
if ($xml->getAttribute("fo:font-weight") == "bold") {
$styles[$name]["tags"][] = "strong";
}
//Creates the style and add <strong> to its tags
if ($xml->getAttribute("style:text-underline-style") == "solid") {
$styles[$name]["tags"][] = "u";
}
//Creates the style and add <u> to its tags
}
}
break;
case "text:note":
if ($_ophir_odt_import_conf["features"]["note"] === 0) {
$xml->next();
break;
} elseif ($_ophir_odt_import_conf["features"]["note"] === 1) {
break;
}
$note_id = $xml->getAttribute("text:id");
$note_name = "Note";
while ($xml->read() && ($xml->name != "text:note" || $xml->nodeType != XMLReader::END_ELEMENT)) {
if ($xml->name == "text:note-citation" && $xml->nodeType == XMLReader::ELEMENT) {
$note_name = $xml->readString();
} elseif ($xml->name == "text:note-body" && $xml->nodeType == XMLReader::ELEMENT) {
$note_content = odt2html($odt_file, $xml->readOuterXML());
}
}
$html .= "<sup><a href=\"#odt-footnote-{$note_id}\" class=\"odt-footnote-anchor\" name=\"anchor-odt-{$note_id}\">{$note_name}</a></sup>";
$footnotes .= "\n" . '<div class="odt-footnote" id="odt-footnote-' . $note_id . '" >';
$footnotes .= '<a class="footnote-name" href="#anchor-odt-' . $note_id . '">' . $note_name . ' .</a> ';
$footnotes .= $note_content;
$footnotes .= '</div>' . "\n";
break;
case "office:annotation":
if ($_ophir_odt_import_conf["features"]["annotation"] === 0) {
$xml->next();
break;
} elseif ($_ophir_odt_import_conf["features"]["annotation"] === 1) {
break;
}
$annotation_id = isset($annotation_id) ? $annotation_id + 1 : 1;
$annotation_content = "";
$annotation_creator = "Anonymous";
$annotation_date = "";
do {
$xml->read();
if ($xml->name == "dc:creator" && $xml->nodeType == XMLReader::ELEMENT) {
$annotation_creator = $xml->readString();
} elseif ($xml->name == "dc:date" && $xml->nodeType == XMLReader::ELEMENT) {
$annotation_date = date("jS \\of F Y, H\\h i\\m", strtotime($xml->readString()));
} elseif ($xml->nodeType == XMLReader::ELEMENT) {
$annotation_content .= $xml->readString();
$xml->next();
}
} while (!($xml->name === "office:annotation" && $xml->nodeType === XMLReader::END_ELEMENT));
//End of the note
$html .= '<sup><a href="#odt-annotation-' . $annotation_id . '" name="anchor-odt-annotation-' . $annotation_id . '" title="Annotation (' . $annotation_creator . ')">(' . $annotation_id . ')</a></sup>';
示例11: readDataBlock
protected function readDataBlock()
{
$v4b43b0aee35624cd95b910189b3dc231 = new XMLReader();
$v4b43b0aee35624cd95b910189b3dc231->open($this->file_path);
$v2245023265ae4cf87d02c8b6ba991139 = mainConfiguration::getInstance();
$vf7c163939469a0b7becb4e4e6a94efac = $v2245023265ae4cf87d02c8b6ba991139->includeParam('system.kernel') . 'subsystems/import/schemes/' . $this->type . '.xsd';
if (is_file($vf7c163939469a0b7becb4e4e6a94efac)) {
$v4b43b0aee35624cd95b910189b3dc231->setSchema($vf7c163939469a0b7becb4e4e6a94efac);
}
$v9a09b4dfda82e3e665e31092d1c3ec8d = new DomDocument("1.0", "utf-8");
$v07214c6750d983a32e0a33da225c4efd = array("Группа", "Товар", "Предложение");
$vc00d122cde678a9551cae41dc45a40b7 = array('ОписаниеГрупп');
$v95723b5e620e47cf613462b9f293282a = 0;
$v4757fe07fd492a8be0ea6a760d683d6e = 0;
$v5f0b6ebc4bea10285ba2b8a6ce78b863 = $v9a09b4dfda82e3e665e31092d1c3ec8d;
$v7aa28ed115707345d0274032757e8991 = $v4b43b0aee35624cd95b910189b3dc231->read();
while ($v7aa28ed115707345d0274032757e8991) {
switch ($v4b43b0aee35624cd95b910189b3dc231->nodeType) {
case XMLReader::ELEMENT:
if (in_array($v4b43b0aee35624cd95b910189b3dc231->name, $vc00d122cde678a9551cae41dc45a40b7)) {
$v7aa28ed115707345d0274032757e8991 = $v4b43b0aee35624cd95b910189b3dc231->next();
continue;
}
if (in_array($v4b43b0aee35624cd95b910189b3dc231->name, $v07214c6750d983a32e0a33da225c4efd)) {
if ($v4757fe07fd492a8be0ea6a760d683d6e++ < $this->offset) {
$v7aa28ed115707345d0274032757e8991 = $v4b43b0aee35624cd95b910189b3dc231->next();
continue 2;
}
if ($v95723b5e620e47cf613462b9f293282a + 1 > $this->block_size) {
if ($v4b43b0aee35624cd95b910189b3dc231->name == "Предложение") {
$vd60db28d94d538bbb249dcc7f2273ab1 = DOMDocument::loadXML($v4b43b0aee35624cd95b910189b3dc231->readOuterXML());
if ($this->__getOffersCompare($v9a09b4dfda82e3e665e31092d1c3ec8d, $vd60db28d94d538bbb249dcc7f2273ab1, $v95723b5e620e47cf613462b9f293282a)) {
break 2;
}
} else {
break 2;
}
}
$v95723b5e620e47cf613462b9f293282a++;
}
$v65c10911d8b8591219a21ebacf46da01 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createElement($v4b43b0aee35624cd95b910189b3dc231->name, $v4b43b0aee35624cd95b910189b3dc231->value);
$v5f0b6ebc4bea10285ba2b8a6ce78b863->appendChild($v65c10911d8b8591219a21ebacf46da01);
if (!$v4b43b0aee35624cd95b910189b3dc231->isEmptyElement) {
$v5f0b6ebc4bea10285ba2b8a6ce78b863 = $v65c10911d8b8591219a21ebacf46da01;
}
if ($v4b43b0aee35624cd95b910189b3dc231->attributeCount) {
while ($v4b43b0aee35624cd95b910189b3dc231->moveToNextAttribute()) {
$v815be97df65d6c4b510cd07189c5347a = $v9a09b4dfda82e3e665e31092d1c3ec8d->createAttribute($v4b43b0aee35624cd95b910189b3dc231->name);
$v815be97df65d6c4b510cd07189c5347a->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createTextNode($v4b43b0aee35624cd95b910189b3dc231->value));
$v65c10911d8b8591219a21ebacf46da01->appendChild($v815be97df65d6c4b510cd07189c5347a);
}
}
$v3f02ab347aeca12e013036ce82046c38 = $this->__getNodePath($v5f0b6ebc4bea10285ba2b8a6ce78b863);
if ($v3f02ab347aeca12e013036ce82046c38 == "КоммерческаяИнформация/Классификатор/Группы") {
$v556216bbe3169f8132fe2b1683164988 = $v4b43b0aee35624cd95b910189b3dc231->readOuterXML();
$v1471e4e05a4db95d353cc867fe317314 = new DOMDocument('1.0', 'utf-8');
$v1471e4e05a4db95d353cc867fe317314->loadXML($v556216bbe3169f8132fe2b1683164988);
$v076933917d4df1df9aeaf50e0d25297b = $v1471e4e05a4db95d353cc867fe317314->getElementsByTagName('Группа');
foreach ($v076933917d4df1df9aeaf50e0d25297b as $vdb0f6f37ebeb6ea09489124345af2a45) {
if ($v4757fe07fd492a8be0ea6a760d683d6e++ < $this->offset) {
continue;
}
if ($v95723b5e620e47cf613462b9f293282a + 1 > $this->block_size) {
break;
}
$this->__collectGroup($v9a09b4dfda82e3e665e31092d1c3ec8d, $v65c10911d8b8591219a21ebacf46da01, $vdb0f6f37ebeb6ea09489124345af2a45);
$v95723b5e620e47cf613462b9f293282a++;
}
$v5f0b6ebc4bea10285ba2b8a6ce78b863 = $v5f0b6ebc4bea10285ba2b8a6ce78b863->parentNode;
$v7aa28ed115707345d0274032757e8991 = $v4b43b0aee35624cd95b910189b3dc231->next();
continue 2;
}
break;
case XMLReader::END_ELEMENT:
$v5f0b6ebc4bea10285ba2b8a6ce78b863 = $v5f0b6ebc4bea10285ba2b8a6ce78b863->parentNode;
break;
case XMLReader::ATTRIBUTE:
$v815be97df65d6c4b510cd07189c5347a = $v9a09b4dfda82e3e665e31092d1c3ec8d->createAttribute($v4b43b0aee35624cd95b910189b3dc231->name);
$v815be97df65d6c4b510cd07189c5347a->appendChild($v9a09b4dfda82e3e665e31092d1c3ec8d->createTextNode($v4b43b0aee35624cd95b910189b3dc231->value));
$v5f0b6ebc4bea10285ba2b8a6ce78b863->appendChild($v815be97df65d6c4b510cd07189c5347a);
break;
case XMLReader::TEXT:
$vc7824f3d4d5f7b2f22d034758c1e9454 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createTextNode($v4b43b0aee35624cd95b910189b3dc231->value);
$v5f0b6ebc4bea10285ba2b8a6ce78b863->appendChild($vc7824f3d4d5f7b2f22d034758c1e9454);
break;
case XMLReader::CDATA:
$vd9ef6bda8fb69f1c7e277bd1c2cd21d1 = $v9a09b4dfda82e3e665e31092d1c3ec8d->createCDATASection($v4b43b0aee35624cd95b910189b3dc231->value);
$v5f0b6ebc4bea10285ba2b8a6ce78b863->appendChild($vd9ef6bda8fb69f1c7e277bd1c2cd21d1);
break;
case XMLReader::NONE:
default:
}
$v7aa28ed115707345d0274032757e8991 = $v4b43b0aee35624cd95b910189b3dc231->read();
}
$this->offset += $v95723b5e620e47cf613462b9f293282a;
if (!$v7aa28ed115707345d0274032757e8991) {
$this->complete = true;
}
return $v9a09b4dfda82e3e665e31092d1c3ec8d;
}
示例12: array
function generate_higher_level_taxa_list($data_dump_url = false)
{
if (!$data_dump_url) {
$data_dump_url = $this->data_dump_url;
}
$path = self::download_and_extract_remote_file($data_dump_url, true);
// true means it will use cache
echo "\n xml file: [{$path}] \n";
$reader = new \XMLReader();
$reader->open($path);
$i = 0;
$sl_taxa = array();
// species-level taxa
$hl_taxa = array();
// higher-level taxa
while (@$reader->read()) {
if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "record") {
$string = $reader->readOuterXML();
$xml = simplexml_load_string($string);
//for species-level taxa
if ($sciname = @$xml->taxonomy->species->taxon->name) {
$sl_taxa["{$sciname}"]["rank"] = "species";
$sl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->species->taxon->taxon_id;
}
//for higher-level taxa
if ($sciname = @$xml->taxonomy->genus->taxon->name) {
$hl_taxa["{$sciname}"]["rank"] = "genus";
$hl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->genus->taxon->taxon_id;
}
if ($sciname = @$xml->taxonomy->subfamily->taxon->name) {
$hl_taxa["{$sciname}"]["rank"] = "subfamily";
$hl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->subfamily->taxon->taxon_id;
}
if ($sciname = @$xml->taxonomy->family->taxon->name) {
$hl_taxa["{$sciname}"]["rank"] = "family";
$hl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->family->taxon->taxon_id;
}
if ($sciname = @$xml->taxonomy->order->taxon->name) {
$hl_taxa["{$sciname}"]["rank"] = "order";
$hl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->order->taxon->taxon_id;
}
if ($sciname = @$xml->taxonomy->class->taxon->name) {
$hl_taxa["{$sciname}"]["rank"] = "class";
$hl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->class->taxon->taxon_id;
}
if ($sciname = @$xml->taxonomy->phylum->taxon->name) {
$hl_taxa["{$sciname}"]["rank"] = "phylum";
$hl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->phylum->taxon->taxon_id;
}
if ($sciname = @$xml->taxonomy->kingdom->taxon->name) {
$hl_taxa["{$sciname}"]["rank"] = "kingdom";
$hl_taxa["{$sciname}"]["taxon_id"] = $xml->taxonomy->kingdom->taxon->taxon_id;
}
}
}
unlink($path);
ksort($hl_taxa);
ksort($sl_taxa);
echo "\n\n higher-level taxa count: " . count($hl_taxa);
$i = 0;
if (!($fn = fopen($this->MASTER_LIST, "w"))) {
debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $this->MASTER_LIST);
return;
}
foreach ($hl_taxa as $key => $value) {
$i++;
echo "\n {$i}. {$key} -- {$value['rank']} {$value['taxon_id']}";
fwrite($fn, $value["taxon_id"] . "\t" . $key . "\t" . $value["rank"] . "\n");
}
echo "\n\n species-level taxa count: " . count($sl_taxa);
echo "\n higher-level taxa count: " . count($hl_taxa);
fclose($fn);
self::reconcile_with_old_master_list($hl_taxa);
// debug - uncomment in normal operation, comment when developing for quick processing
}
示例13: export
public function export($v92ec19ffde05e15769b1bb3ee05ad745)
{
set_time_limit(0);
if (!count($v92ec19ffde05e15769b1bb3ee05ad745)) {
$v8be74552df93e31bbdd6b36ed74bdb6a = new selector('pages');
$v8be74552df93e31bbdd6b36ed74bdb6a->where('hierarchy')->page(0)->childs(0);
$v92ec19ffde05e15769b1bb3ee05ad745 = $v8be74552df93e31bbdd6b36ed74bdb6a->result;
}
if (getRequest('as_file') === '0') {
$ved780287e302ec3b9fd3c5e78771919f = new xmlExporter($this->getSourceName());
$ved780287e302ec3b9fd3c5e78771919f->addBranches($v92ec19ffde05e15769b1bb3ee05ad745);
$result = $ved780287e302ec3b9fd3c5e78771919f->execute();
return $result->saveXML();
}
$v857a5246dff0c3c79e476b004684f6d3 = "./sys-temp/export/";
$vb80bb7740288fda1f201890375a60c8f = getRequest('param0');
$v97fd815a3803a0588876bdd862014fed = $v857a5246dff0c3c79e476b004684f6d3 . $vb80bb7740288fda1f201890375a60c8f . "." . parent::getFileExt();
$v6990a54322d9232390a784c5c9247dd6 = $v857a5246dff0c3c79e476b004684f6d3 . $vb80bb7740288fda1f201890375a60c8f;
if (!is_dir($v6990a54322d9232390a784c5c9247dd6)) {
mkdir($v6990a54322d9232390a784c5c9247dd6, 0777, true);
}
if (file_exists($v97fd815a3803a0588876bdd862014fed) && !file_exists(CURRENT_WORKING_DIR . '/sys-temp/runtime-cache/' . md5($this->getSourceName()))) {
unlink($v97fd815a3803a0588876bdd862014fed);
}
if ($v92ec19ffde05e15769b1bb3ee05ad745) {
$v33030abc929f083da5f6c3f755b46034 = array('./tpls/', './xsltTpls/', './css/', './js/', './usels/', './umaps/', './templates/');
foreach ($v33030abc929f083da5f6c3f755b46034 as $v100664c6e2c0333b19a729f2f3ddb7dd) {
if (is_dir($v100664c6e2c0333b19a729f2f3ddb7dd)) {
$v736007832d2167baaae763fd3a3f3cf1 = new umiDirectory($v100664c6e2c0333b19a729f2f3ddb7dd);
$v45b963397aa40d4a0063e0d85e4fe7a1 = $v736007832d2167baaae763fd3a3f3cf1->getAllFiles(1);
foreach ($v45b963397aa40d4a0063e0d85e4fe7a1 as $vd6fe1d0be6347b8ef2427fa629c04485 => $vb068931cc450442b63f5b3d276ea4297) {
$v8c7dd922ad47494fc02c388e12c00eac = new umiFile($vd6fe1d0be6347b8ef2427fa629c04485);
if (!is_dir($v6990a54322d9232390a784c5c9247dd6 . ltrim($v8c7dd922ad47494fc02c388e12c00eac->getDirName(), '.'))) {
mkdir($v6990a54322d9232390a784c5c9247dd6 . ltrim($v8c7dd922ad47494fc02c388e12c00eac->getDirName(), '.'), 0777, true);
}
copy($v8c7dd922ad47494fc02c388e12c00eac->getFilePath(), $v6990a54322d9232390a784c5c9247dd6 . $v8c7dd922ad47494fc02c388e12c00eac->getFilePath(true));
}
}
}
}
$v71b70dd1e455c477220693d84ccd5682 = $v97fd815a3803a0588876bdd862014fed . '.tmp';
$v480d1b61a0432d1319f7504a3d7318dd = (int) mainConfiguration::getInstance()->get("modules", "exchange.export.limit");
if ($v480d1b61a0432d1319f7504a3d7318dd <= 0) {
$v480d1b61a0432d1319f7504a3d7318dd = 25;
}
$ved780287e302ec3b9fd3c5e78771919f = new xmlExporter($this->getSourceName(), $v480d1b61a0432d1319f7504a3d7318dd);
$ved780287e302ec3b9fd3c5e78771919f->addBranches($v92ec19ffde05e15769b1bb3ee05ad745);
$vdd988cfd769c9f7fbd795a0f5da8e751 = $ved780287e302ec3b9fd3c5e78771919f->execute();
if (file_exists($v97fd815a3803a0588876bdd862014fed)) {
$v1de9b0a30075ae8c303eb420c103c320 = new XMLReader();
$va82feee3cc1af8bcabda979e8775ef0f = new XMLWriter();
$v1de9b0a30075ae8c303eb420c103c320->open($v97fd815a3803a0588876bdd862014fed);
$va82feee3cc1af8bcabda979e8775ef0f->openURI($v71b70dd1e455c477220693d84ccd5682);
$va82feee3cc1af8bcabda979e8775ef0f->startDocument('1.0', 'utf-8');
$va82feee3cc1af8bcabda979e8775ef0f->startElement('umidump');
$va82feee3cc1af8bcabda979e8775ef0f->writeAttribute('version', '2.0');
$va82feee3cc1af8bcabda979e8775ef0f->writeAttribute('xmlns:xlink', 'http://www.w3.org/TR/xlink');
$v7aa28ed115707345d0274032757e8991 = $v1de9b0a30075ae8c303eb420c103c320->read();
while ($v7aa28ed115707345d0274032757e8991) {
if ($v1de9b0a30075ae8c303eb420c103c320->nodeType == XMLReader::ELEMENT) {
$ve24455211a964330063a18670d943835 = $v1de9b0a30075ae8c303eb420c103c320->name;
if ($ve24455211a964330063a18670d943835 != 'umidump') {
$va82feee3cc1af8bcabda979e8775ef0f->startElement($ve24455211a964330063a18670d943835);
if ($ve24455211a964330063a18670d943835 != 'meta') {
if (!$v1de9b0a30075ae8c303eb420c103c320->isEmptyElement) {
$v7852ddca47412c0d947ebf27eb83ed3a = $v1de9b0a30075ae8c303eb420c103c320->read();
while ($v7852ddca47412c0d947ebf27eb83ed3a) {
if ($v1de9b0a30075ae8c303eb420c103c320->nodeType == XMLReader::ELEMENT) {
$vcf7f5c76225a101e6320a96c02f92fc1 = $v1de9b0a30075ae8c303eb420c103c320->name;
$va82feee3cc1af8bcabda979e8775ef0f->writeRaw($v1de9b0a30075ae8c303eb420c103c320->readOuterXML());
$v7852ddca47412c0d947ebf27eb83ed3a = $v1de9b0a30075ae8c303eb420c103c320->next();
} elseif ($v1de9b0a30075ae8c303eb420c103c320->nodeType == XMLReader::END_ELEMENT && $v1de9b0a30075ae8c303eb420c103c320->name == $ve24455211a964330063a18670d943835) {
$v7852ddca47412c0d947ebf27eb83ed3a = false;
} else {
$v7852ddca47412c0d947ebf27eb83ed3a = $v1de9b0a30075ae8c303eb420c103c320->next();
}
}
}
if ($vdd988cfd769c9f7fbd795a0f5da8e751->getElementsByTagName($ve24455211a964330063a18670d943835)->item(0)->hasChildNodes()) {
$v268184c12df027f536154d099d497b31 = $vdd988cfd769c9f7fbd795a0f5da8e751->getElementsByTagName($ve24455211a964330063a18670d943835)->item(0)->childNodes;
foreach ($v268184c12df027f536154d099d497b31 as $v1b7d5726533ab525a8760351e9b5e415) {
$va5e171f642af8e3bd24c50cdc4d66fe3 = new DOMDocument();
$va5e171f642af8e3bd24c50cdc4d66fe3->formatOutput = true;
$v36c4536996ca5615dcf9911f068786dc = $va5e171f642af8e3bd24c50cdc4d66fe3->importNode($v1b7d5726533ab525a8760351e9b5e415, true);
$va5e171f642af8e3bd24c50cdc4d66fe3->appendChild($v36c4536996ca5615dcf9911f068786dc);
$va82feee3cc1af8bcabda979e8775ef0f->writeRaw($va5e171f642af8e3bd24c50cdc4d66fe3->saveXML($v36c4536996ca5615dcf9911f068786dc, LIBXML_NOXMLDECL));
}
}
} elseif ($ve24455211a964330063a18670d943835 == 'meta') {
$va82feee3cc1af8bcabda979e8775ef0f->writeRaw($v1de9b0a30075ae8c303eb420c103c320->readInnerXML());
$v92ec19ffde05e15769b1bb3ee05ad745 = $vdd988cfd769c9f7fbd795a0f5da8e751->getElementsByTagName('branches');
if ($v92ec19ffde05e15769b1bb3ee05ad745->item(0)) {
$va82feee3cc1af8bcabda979e8775ef0f->writeRaw($vdd988cfd769c9f7fbd795a0f5da8e751->saveXML($v92ec19ffde05e15769b1bb3ee05ad745->item(0), LIBXML_NOXMLDECL));
}
}
$va82feee3cc1af8bcabda979e8775ef0f->fullEndElement();
$v7aa28ed115707345d0274032757e8991 = $v1de9b0a30075ae8c303eb420c103c320->next();
continue;
}
}
//.........这里部分代码省略.........
示例14: importProducts
/**
* Import products to temp table
*
* @param $filename
* @return string
*/
private function importProducts($filename)
{
// Последний товар, на котором остановились
$lastImportProduct = $this->options['lastImportProduct'];
$firstImport = empty($lastImportProduct) ? 1 : 0;
//clear temp category table
if ($firstImport) {
$this->modx->exec("TRUNCATE TABLE {$this->modx->getTableName('mSkladProductTemp')}");
}
$reader = new XMLReader();
$reader->open($this->config['temp_dir'] . $filename);
//search products
while ($reader->read() && $reader->name !== 'Товар') {
}
// Номер текущего товара
$currentImportProduct = 0;
$prodSql = array();
while ($reader->name === 'Товар') {
if ($firstImport || $currentImportProduct > $lastImportProduct) {
$xml = new SimpleXMLElement($reader->readOuterXML());
$prod_name = isset($xml->Наименование) ? addslashes((string) $xml->Наименование) : '';
$prod_description = isset($xml->Описание) ? addslashes((string) $xml->Описание) : '';
//standart properties
$prod_article = isset($xml->Артикул) ? addslashes((string) $xml->Артикул) : '';
$prod_manufacturer = isset($xml->Изготовитель) ? addslashes((string) $xml->Изготовитель->Наименование) : '';
$prod_bar_code = isset($xml->Штрихкод) ? addslashes((string) $xml->Штрихкод) : '';
//additional properties
$prod_properties = array();
if (isset($xml->ЗначенияСвойств)) {
foreach ($xml->ЗначенияСвойств->ЗначенияСвойства as $xml_property) {
$propertyId = addslashes((string) $xml_property->Ид);
$propertyData = $_SESSION['properties_mapping'][$propertyId];
$propertyName = $propertyData['Наименование'];
$propertyVal = addslashes((string) $xml_property->Значение);
if (isset($propertyData['Значения'])) {
$propertyVal = $propertyData['Значения'][$propertyVal];
}
if (!empty($propertyVal)) {
$prod_properties[$propertyName] = $propertyVal;
}
}
}
if (isset($xml->СписокСвойствОписания)) {
foreach ($xml->СписокСвойствОписания->СвойствоОписания as $xml_property) {
$propertyName = addslashes((string) $xml_property->Наименование);
$propertyVal = addslashes((string) $xml_property->Значение);
if (!empty($propertyVal)) {
if (!isset($prod_properties[$propertyName]) && !empty($propertyVal)) {
$prod_properties[$propertyName] = $propertyVal;
}
}
}
}
if (isset($xml->ЗначенияРеквизитов)) {
foreach ($xml->ЗначенияРеквизитов->ЗначениеРеквизита as $xml_property) {
$propertyName = addslashes((string) $xml_property->Наименование);
$propertyVal = addslashes((string) $xml_property->Значение);
if ($propertyName == 'ВидНоменклатуры' || $propertyName == 'ТипНоменклатуры') {
continue;
}
if (!empty($propertyVal)) {
if (!isset($prod_properties[$propertyName]) && !empty($propertyVal)) {
$prod_properties[$propertyName] = $propertyVal;
}
}
}
}
$prod_properties = addslashes($this->modx->msklad->utf_json_encode($prod_properties));
//
$prod_images = addslashes($this->modx->msklad->utf_json_encode((array) $xml->Картинка));
$prod_features = addslashes($this->modx->msklad->utf_json_encode((array) $xml->ХарактеристикиТовара));
$prod_uuid = isset($xml->Ид) ? addslashes((string) $xml->Ид) : '';
$prod_parent_uuid = isset($xml->Группы->Ид) ? addslashes((string) $xml->Группы->Ид) : '';
$prod_status = isset($xml->Статус) ? addslashes((string) $xml->Статус) : '';
if (count($prodSql) < 200) {
$prodSql[] = "('{$prod_name}', '{$prod_article}', '{$prod_manufacturer}', '{$prod_images}', '{$prod_bar_code}', '{$prod_description}', '{$prod_features}', '{$prod_properties}', '{$prod_uuid}', '{$prod_parent_uuid}', '{$prod_status}')";
} else {
$sql = "INSERT INTO " . $this->modx->getTableName('mSkladProductTemp') . " (`name`, `article`, `manufacturer`, `images`, `bar_code`, `description`, `features`, `properties`, `uuid`, `parent_uuid`, `status`) VALUES\n\t\t\t\t\t\t " . implode(',', $prodSql) . ";";
$stmt = $this->modx->prepare($sql);
$stmt->execute();
$prodSql = array();
}
$lastImportProduct = $_SESSION['lastImportProduct'] = $currentImportProduct;
//if exec time more max time, break cycle
$exec_time = microtime(true) - $this->config['start_time'];
if ($exec_time + 1 >= $this->config['max_exec_time']) {
break;
}
}
$reader->next('Товар');
$currentImportProduct++;
}
$reader->close();
//if isset insert query
//.........这里部分代码省略.........
示例15: player_enc
public function player_enc($sport='',$filenum=''){
//$this->output->enable_profiler(TRUE);
$debug=true;
if(empty($sport))$sport=strtolower($this->uri->segment(3));
if(empty($filenum))$filenum=strtolower($this->uri->segment(4));
if(!empty($sport)){
if($sport=="nfl"){
if(empty($filenum)) exit;
$filename="NFL_PLAYER_ENC\$".$filenum.".XML";
$url=$this->statspath.$filename;
$layer1="nfl-player-encyclopedia";
$layer2="nfl-player-encyclopedia-year";
$career="nfl-player-encyclopedia-career";
$categories=array(
"games"=>"nfl-player-encyclopedia-games",
"offense"=>"nfl-player-encyclopedia-offense",
"defense"=>"nfl-player-encyclopedia-defense",
"misc"=>"nfl-player-encyclopedia-miscellaneous",
"kicking"=>"nfl-player-encyclopedia-kicking",
"punting"=>"nfl-player-encyclopedia-punting",
"returning"=>"nfl-player-encyclopedia-returning",
"offline"=>"nfl-player-encyclopedia-off-line",
"fumbles"=>"nfl-player-encyclopedia-fumbles",
);
}elseif($sport=="nba"){
$filename="NBA_PLAYER_ENC.XML";
$url=$this->statspath.$filename;
$layer1="nba-player-encyclopedia";
$layer2="nba-player-encyclopedia-year";
$career="nba-player-encyclopedia-career";
$skip=array("team-name","team-city","team-code");
}elseif($sport=="cbk"){
if(empty($filenum)) exit;
$filename="CBK_PLAYER_ENC\$".$filenum.".XML";
$url=$this->statspath.$filename;
$layer1="cbk-player-encyclopedia";
$layer2="cbk-player-encyclopedia-year";
$career="cbk-player-encyclopedia-career";
$skip=array("team-name","team-city","team-code");
}elseif($sport=="cfb"){
if(empty($filenum)) exit;
$filename="CFB_PLAYER_ENC\$".$filenum.".XML";
$url=$this->statspath.$filename;
$layer1="cfb-player-encyclopedia";
$layer2="cfb-player-encyclopedia-year";
$career="cfb-player-encyclopedia-career";
$skip=array("team-name","team-city","team-code");
}elseif($sport=="nhl"){
if(empty($filenum)) exit;
$filename="NHL_PLAYER_ENC\$".$filenum.".XML";
$url=$this->statspath.$filename;
$layer1="nhl-player-encyclopedia";
$layer2="nhl-player-encyclopedia-year";
$career="nhl-player-encyclopedia-career";
$categories=array(
"skating"=>"nhl-skating-stats",
"goaltending"=>"nhl-goaltending-stats",
);
$skip=array("team-name","team-city","team-code","sequence");
//DELETE FROM `ci_sport_player_career` WHERE `player_id` IN (301772,301769,543573,225414,296021,231130,178023,329643,550521,386807,170695,542954,392942,184268,549269,504293,170560,600117,171423,547716,330276,268149,504313,564333,607591,229378,172508,610878,544288,496357,329563)
}elseif($sport=="mlb"){
if(empty($filenum)) exit;
$filename="MLB_PLAYER_ENC\$".$filenum.".XML";
$url=$this->statspath.$filename;
$layer1="baseball-mlb-player-encyclopedia";
$layer2="baseball-mlb-player-encyclopedia-year";
$career=false;
$categories=array(
"hitting"=>"baseball-mlb-player-encyclopedia-hitting",
"pitching"=>"baseball-mlb-player-encyclopedia-pitching",
"fielding"=>"baseball-mlb-player-encyclopedia-fielding",
);
$skip=array("team-name","team-city","team-code","sequence");
}elseif($sport=="golf"){
$filename="GOLF_GOLFER_ENC_PGA.XML";
$url=$this->statspath.$filename;
$layer1="golfer-encyclopedia";
$layer2="golfer-encyclopedia-year";
$career="golfer-encyclopedia-career";
$skip=array();
}
echo ($debug)?"<a href='".site_url("statsfeed/".$filename)."'>XML</a>":"";
$XMLReader = new XMLReader;
$xml_file_path=$this->statspath.$filename;
$XMLReader->open($xml_file_path);
$player_ids=array();
while ($XMLReader->read() && $XMLReader->name !==$layer1);
while ($XMLReader->name === $layer1) {
$node = new SimpleXMLElement($XMLReader->readOuterXML());
if($sport=='golf'){
$player_id=(int)$node->{'golfer-code'}->attributes()->{'global-id'};
}else{
$player_id=(int)$node->{'player-code'}->attributes()->{'global-id'};
}
//Delete this user's existing data
$this->db->where('player_id',$player_id);
$this->db->delete('sport_player_career');
//.........这里部分代码省略.........