当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLReader::moveToAttribute方法代码示例

本文整理汇总了PHP中XMLReader::moveToAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLReader::moveToAttribute方法的具体用法?PHP XMLReader::moveToAttribute怎么用?PHP XMLReader::moveToAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLReader的用法示例。


在下文中一共展示了XMLReader::moveToAttribute方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateVersionInfo

 public static function generateVersionInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     if (!is_file($filename)) {
         v("Can't find Version information file (%s), skipping!", $filename, E_USER_WARNING);
         return array();
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         v("Can't open the version info file (%s)", $filename, E_USER_ERROR);
     }
     $versions = array();
     while ($r->read()) {
         if ($r->moveToAttribute("name") && ($funcname = str_replace(array("::", "->", "__", "_", '$'), array("-", "-", "-", "-", ""), $r->value)) && $r->moveToAttribute("from") && ($from = $r->value)) {
             $versions[strtolower($funcname)] = $from;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $versions;
     return $versions;
 }
开发者ID:robertop,项目名称:phd,代码行数:25,代码来源:XHTML.php

示例2: generateVersionInfo

 public static function generateVersionInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         throw new \Exception("Could not open file for accessing version information: {$filename}");
     }
     $versions = array();
     while ($r->read()) {
         if ($r->moveToAttribute("name") && ($funcname = str_replace(array("::", "->", "__", "_", '$'), array("-", "-", "-", "-", ""), $r->value)) && $r->moveToAttribute("from") && ($from = $r->value)) {
             $versions[strtolower($funcname)] = $from;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $versions;
     return $versions;
 }
开发者ID:philip,项目名称:phd,代码行数:21,代码来源:XHTML.php

示例3: getWeather

/** GET WEATHER * */
function getWeather($w = '', $u = 'c')
{
    $wURI = 'API';
    $weather = array();
    $reader = new XMLReader();
    $reader->open($wURI);
    $i = -1;
    while ($reader->read()) {
        if (strpos($reader->name, "yweather") !== false && $reader->hasAttributes) {
            switch ($reader->localName) {
                case 'atmosphere':
                    $reader->moveToAttribute('humidity');
                    $weather['humidity'] = $reader->value;
                    $reader->moveToAttribute('pressure');
                    $weather['pressure'] = $reader->value;
                    break;
                case 'astronomy':
                    $reader->moveToAttribute('sunrise');
                    $weather['sunrise'] = $reader->value;
                    $reader->moveToAttribute('sunset');
                    $weather['sunset'] = $reader->value;
                    break;
                case 'condition':
                    $reader->moveToAttribute('text');
                    $weather['text'] = $reader->value;
                    $reader->moveToAttribute('code');
                    $weather['code'] = $reader->value;
                    $reader->moveToAttribute('temp');
                    $weather['temperature'] = $reader->value;
                    break;
                case 'forecast':
                    $i++;
                    $reader->moveToAttribute('date');
                    $weather['forecast'][$i]['date'] = $reader->value;
                    $reader->moveToAttribute('low');
                    $weather['forecast'][$i]['low'] = $reader->value;
                    $reader->moveToAttribute('high');
                    $weather['forecast'][$i]['high'] = $reader->value;
                    $reader->moveToAttribute('text');
                    $weather['forecast'][$i]['text'] = $reader->value;
                    break;
            }
        }
    }
    if ($i == -1) {
        return false;
    } else {
        return $weather;
    }
}
开发者ID:superego546,项目名称:SMSGyan,代码行数:51,代码来源:weatherY.php

示例4: generate

 /**
  * Generates the report by processing the XML file.
  * @param array $params 
  */
 public function generate($params)
 {
     $report = $this->getReport();
     $reader = new XMLReader();
     $reader->XML($this->xml->asXML());
     while ($reader->read()) {
         if ($reader->nodeType !== XMLReader::ELEMENT) {
             continue;
         }
         switch ($reader->name) {
             case "rapi:logo":
                 if ($_POST["hide_logo"] == 1) {
                     $text = new TextContent();
                     $text->style["flow"] = true;
                     $text->setText("\n\n\n\n\n\n\n\n");
                     $report->add($text);
                 } else {
                     $reader->moveToAttribute("class");
                     $class = $reader->value;
                     $logo = $class == '' ? new LogoContent() : new $class();
                     $report->add($logo);
                     $report->logo = $logo;
                 }
                 break;
             case "rapi:text":
                 $text = new TextContent();
                 $reader->moveToAttribute("style");
                 switch ($reader->value) {
                     case "heading":
                         $text->style["size"] = 16;
                         $text->style["font"] = "Helvetica";
                         $text->style["bold"] = true;
                         $report->label = $text;
                         break;
                     default:
                         $text->style["size"] = $reader->moveToAttribute("size") ? $reader->value : 12;
                         $text->style["font"] = $reader->value ? $reader->moveToAttribute("font") : "Helvetica";
                         break;
                 }
                 $reader->read();
                 $text->setText($reader->value);
                 $report->add($text);
                 break;
             case "rapi:table":
                 $numConcatFields = 0;
                 $reader->moveToAttribute("name");
                 $name = $reader->value;
                 $tableConditionsArray = array();
                 if ($reader->moveToAttribute("conditions")) {
                     $tableConditionsArray[] = $reader->value;
                 }
                 if ($this->tableConditions != '') {
                     $tableConditionsArray[] = $this->tableConditions;
                 }
                 $tableConditions = implode(" AND ", $tableConditionsArray);
                 $fields = $this->xml->xpath("/rapi:report/rapi:table[@name='{$name}']/rapi:fields/rapi:field");
                 $headers = $this->xml->xpath("/rapi:report/rapi:table[@name='{$name}']/rapi:fields/rapi:field[@label!='']/@label");
                 $dontJoins = $this->xml->xpath("/rapi:report/rapi:table[@name='{$name}']/rapi:dont_join/rapi:pair");
                 $ignoredFields = array();
                 $dataParams["total"] = array();
                 $hardCodedSorting = array();
                 $reportGroupingFields = array();
                 $models = array();
                 $fieldInfos = array();
                 // Generate filter conditions
                 $filters = array();
                 $filterSummaries = array();
                 $keyOffset = 0;
                 foreach ($fields as $key => $field) {
                     // Load the model for this field if it hasn't been
                     // loaded already. I have a hunch that this check
                     // is really not necessary since the model loader
                     // sort of caches loaded models now.
                     $modelInfo = Model::resolvePath((string) $field);
                     if (array_search($modelInfo["model"], array_keys($models)) === false) {
                         $models[$modelInfo["model"]] = Model::load($modelInfo["model"]);
                     }
                     $model = $models[$modelInfo["model"]];
                     $fieldInfo = $model->getFields(array($modelInfo["field"]));
                     $fieldInfo = $fieldInfo[0];
                     $fieldInfos[(string) $field] = $fieldInfo;
                     //Ignore fields which are not needed.
                     if (isset($_POST[$name . "_" . $fieldInfo["name"] . "_ignore"])) {
                         $ignoredFields[] = $key;
                     }
                     if (isset($field["sort"])) {
                         $sortField = "{$model->database}.{$fieldInfo["name"]}";
                         $hardCodedSorting[] = array("field" => $sortField, "type" => $field["sort"]);
                     }
                     if (isset($field["labelsField"])) {
                         $dynamicFields[] = (string) $field;
                         $dynamicHeaders[] = (string) $field["labelsField"];
                         $labelModelInfo = Model::resolvePath($field["labelsField"]);
                         $headersModel = Model::load($labelModelInfo["model"]);
                         $dynamicHeaderValues = $headersModel->get(array("fields" => array($labelModelInfo["field"])), SQLDataBaseModel::MODE_ARRAY);
                         foreach ($dynamicHeaderValues as $headerValue) {
//.........这里部分代码省略.........
开发者ID:ekowabaka,项目名称:cfx,代码行数:101,代码来源:XmlDefinedReportController.php

示例5: parse

 public function parse($source)
 {
     if (preg_match('/flickr/', $source)) {
         $isFlickr = 1;
     }
     if (!$this->report) {
         error_reporting(0);
     }
     if ($this->returns) {
         $returns = $this->returns;
     } else {
         $returns = 5;
     }
     $feedLinks = -1;
     $feedCategories = -1;
     $feedAuthorsCount = -1;
     $itemLinks = -1;
     $itemCategories = -1;
     $reader = new \XMLReader();
     $cachedCopy = "pgcache/" . urlencode($source);
     if (file_exists($cachedCopy)) {
         $cacheTime = filemtime($cachedCopy);
         $now = time();
         $age = $now - $cacheTime;
     }
     if (file_exists($cachedCopy) && $this->cache && $age > $this->cache || !file_exists($cachedCopy)) {
         try {
             PGFeed::checkSource($source);
         } catch (Exception $e) {
             if ($this->report) {
                 echo 'Message: ' . $e->getMessage();
             }
             die;
         }
         if ($this->cache) {
             PGFeed::cacheFeed($source);
         }
         $reader->open($source);
     } else {
         $cachedContents = file_get_contents($cachedCopy);
         $reader->XML($cachedContents);
     }
     while ($reader->read()) {
         $name = $reader->name;
         if ($name == "feed" && $reader->nodeType == 1) {
             $isAtom = 1;
         } else {
             if (in_array("{$name}", $this->channelElements) && $reader->nodeType == 1 && !$isInItem && !$isInImage && !$isAtom) {
                 $reader->read();
                 $this->channel["{$name}"] = $reader->value;
             } else {
                 if ($name == "cloud" && $reader->nodeType == 1 && !$isAtom) {
                     foreach ($this->cloudAttributes as $att) {
                         if ($reader->moveToAttribute("{$att}")) {
                             $this->channel["cloud"]["{$att}"] = $reader->value;
                         }
                     }
                 } else {
                     if ($name == "image" && $reader->nodeType == 1 && !$isAtom) {
                         $isInImage = 1;
                     } else {
                         if ($name == "image" && $reader->nodeType == 15 && !$isAtom) {
                             $isInImage = 0;
                         } else {
                             if (in_array("{$name}", $this->imageElements) && $reader->nodeType == 1 && $isInImage && !$isAtom) {
                                 $reader->read();
                                 $this->channel["image"]["{$name}"] = $reader->value;
                             } else {
                                 if ($name == "textInput" && $reader->nodeType == 1 && !$isAtom) {
                                     $isInTextInput = 1;
                                 } else {
                                     if ($name == "textInput" && $reader->nodeType == 15 && !$isAtom) {
                                         $isInTextInput = 0;
                                     } else {
                                         if (in_array("{$name}", $this->textInputElements) && $reader->nodeType == 1 && $isInTextInput && !$isAtom) {
                                             $reader->read();
                                             $this->channel["textInput"]["{$name}"] = $reader->value;
                                         } else {
                                             if ($name == "item" && $reader->nodeType == 1 && !$isAtom) {
                                                 $isInItem = 1;
                                                 $itemNumber++;
                                                 $item = array();
                                             } else {
                                                 if (in_array("{$name}", $this->itemElements) && $reader->nodeType == 1 && $isInItem && !$isAtom) {
                                                     $reader->read();
                                                     $item["{$name}"] = $reader->value;
                                                 } else {
                                                     if ($name == "description" && $reader->nodeType == 1 && $isInItem && !$isAtom) {
                                                         $isInDescription = 1;
                                                         $reader->read();
                                                         $description = $reader->value;
                                                         if ($this->strip) {
                                                             $newDescription = preg_replace("/<.+?>/", "", $description);
                                                         } else {
                                                             $newDescription = $description;
                                                         }
                                                         $item["description"] = $newDescription;
                                                     } else {
                                                         if ($name == "description" && $reader->nodeType == 15) {
                                                             $isInDescription = 0;
//.........这里部分代码省略.........
开发者ID:kenirwin,项目名称:SubjectsPlus,代码行数:101,代码来源:PGFeed.php

示例6: attr

 if ($reader->nodeType != XMLREADER::END_ELEMENT) {
     if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) {
         $attr = $reader->moveToFirstAttribute();
         echo $reader->name . ": ";
         echo $reader->value . "\n";
         if ($reader->getAttribute($reader->name) == $reader->value) {
             echo "1st attr (num) failed\n";
         }
         $attr = $reader->moveToNextAttribute();
         echo $reader->name . ": ";
         echo $reader->value . "\n";
         if ($reader->getAttribute($reader->name) == $reader->value) {
             echo "2nd attr (idx) failed\n";
         }
         // Named attribute
         $attr = $reader->moveToAttribute('num');
         echo $reader->name . ": ";
         echo $reader->value . "\n";
         if ($reader->getAttribute('num') == $reader->value) {
             echo "attr num failed\n";
         }
         $attr = $reader->moveToAttribute('idx');
         echo $reader->name . ": ";
         echo $reader->value . "\n";
         if ($reader->getAttribute('idx') == $reader->value) {
             echo "attr idx failed\n";
         }
         // Numeric positions of attributes
         $attr = $reader->moveToAttributeNo(0);
         echo $reader->name . ": ";
         echo $reader->value . "\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:003.php

示例7: generateVersionInfo

 public static function generateVersionInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         throw new \Exception();
     }
     $versions = array();
     while ($r->read()) {
         if ($r->moveToAttribute('name') && ($funcname = str_replace(array('::', '->', '__', '_', '$'), array('-', '-', '-', '-', ''), $r->value)) && $r->moveToAttribute('from') && ($from = $r->value)) {
             $versions[strtolower($funcname)] = $from;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $versions;
     return $versions;
 }
开发者ID:TazeTSchnitzel,项目名称:phd,代码行数:21,代码来源:Base.php

示例8: XMLReader

}
if (file_exists($uploadfile)) {
    $reader = new XMLReader();
    $reader->open($uploadfile);
    echo "<p align=\"center\"><b>XML file successfully opened.</b></p>";
} else {
    echo "<p align=\"center\"><b>Failed to open the xml file.</b></p>";
    exit;
}
echo "<hr>";
include '../main/config.php';
require_once 'DB.php';
$db = DB::connect("mysql://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}");
while ($reader->read()) {
    if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "XmlReport") {
        $reader->moveToAttribute('Name');
        $XmlReport_Name = mysql_prep($reader->value);
    }
    /*--------------------------------------------------------------------------
    		SUMMARY
    --------------------------------------------------------------------------*/
    if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "Summary") {
        $isSummary = "true";
    }
    if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "TotalIssues" && $isSummary == "true") {
        $reader->read();
        $TotalIssues = mysql_prep($reader->value);
    }
    if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == "TotalVariants" && $isSummary == "true") {
        $reader->read();
        $TotalVariants = mysql_prep($reader->value);
开发者ID:mageni,项目名称:projectrf,代码行数:31,代码来源:parse.php

示例9: generateDeprecatedInfo

 protected static function generateDeprecatedInfo($filename)
 {
     static $info;
     if ($info) {
         return $info;
     }
     if (!is_file($filename)) {
         v("Can't find Version information file (%s), skipping!", $filename, E_USER_WARNING);
         return array();
     }
     $r = new \XMLReader();
     if (!$r->open($filename)) {
         v("Can't open the version info file (%s)", $filename, E_USER_ERROR);
     }
     $deprecated = array();
     while ($r->read()) {
         if ($r->moveToAttribute("name") && ($funcname = str_replace(array("::", "->", "__", "_", '$'), array("_", "_", "_", "_", ""), $r->value)) && $r->moveToAttribute("deprecated") && ($value = $r->value)) {
             $deprecated[strtolower($funcname)] = $value;
             $r->moveToElement();
         }
     }
     $r->close();
     $info = $deprecated;
     return $deprecated;
 }
开发者ID:TazeTSchnitzel,项目名称:phd,代码行数:25,代码来源:XHTML.php

示例10: XMLReader

<?php

$reader = new XMLReader();
$reader->XML($catalog);
/* Loop through document */
while ($reader->read()) {
    /* If you're at an element named 'book' */
    if ($reader->nodeType == XMLREADER::ELEMENT && $reader->localName == 'book') {
        $reader->moveToAttribute('isbn');
        print $reader->value . "\n";
    }
}
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:12,代码来源:parse-xml6.php

示例11: parse

 function parse($source)
 {
     if (!$this->report) {
         error_reporting(0);
     }
     if (!is_null($this->returns)) {
         $returns = $this->returns;
     } else {
         $returns = 12;
     }
     $feedLinks = -1;
     $feedCategories = -1;
     $feedAuthorsCount = -1;
     $itemLinks = -1;
     $itemCategories = -1;
     $reader = new XMLReader();
     $cachedCopy = "pgcache/" . urlencode($source);
     if (file_exists($cachedCopy)) {
         $cacheTime = filemtime($cachedCopy);
         $now = time();
         $age = $now - $cacheTime;
     }
     if (file_exists($cachedCopy) && $this->cache && $age > $this->cache || !file_exists($cachedCopy)) {
         try {
             PGFeed::checkSource($source);
         } catch (Exception $e) {
             if ($this->report) {
                 echo 'Message: ' . $e->getMessage();
             }
             die;
         }
         if ($this->cache) {
             PGFeed::cacheFeed($source);
         }
         $reader->open($source);
     } else {
         $cachedContents = file_get_contents($cachedCopy);
         $reader->XML($cachedContents);
     }
     while ($reader->read()) {
         $name = $reader->name;
         if ($name == "feed" && $reader->nodeType == 1) {
             $isAtom = 1;
         } else {
             if (in_array("{$name}", $this->channelElements) && $reader->nodeType == 1 && !$isInItem && !$isInImage && !$isAtom) {
                 $reader->read();
                 $this->channel["{$name}"] = $reader->value;
             } else {
                 if ($name == "cloud" && $reader->nodeType == 1 && !$isAtom) {
                     foreach ($this->cloudAttributes as $att) {
                         if ($reader->moveToAttribute("{$att}")) {
                             $this->channel["cloud"]["{$att}"] = $reader->value;
                         }
                     }
                 } else {
                     if ($name == "image" && $reader->nodeType == 1 && !$isAtom) {
                         $isInImage = 1;
                     } else {
                         if ($name == "image" && $reader->nodeType == 15 && !$isAtom) {
                             $isInImage = 0;
                         } else {
                             if (in_array("{$name}", $this->imageElements) && $reader->nodeType == 1 && $isInImage && !$isAtom) {
                                 $reader->read();
                                 $this->channel["image"]["{$name}"] = $reader->value;
                             } else {
                                 if ($name == "textInput" && $reader->nodeType == 1 && !$isAtom) {
                                     $isInTextInput = 1;
                                 } else {
                                     if ($name == "textInput" && $reader->nodeType == 15 && !$isAtom) {
                                         $isInTextInput = 0;
                                     } else {
                                         if (in_array("{$name}", $this->textInputElements) && $reader->nodeType == 1 && $isInTextInput && !$isAtom) {
                                             $reader->read();
                                             $this->channel["textInput"]["{$name}"] = $reader->value;
                                         } else {
                                             if ($name == "item" && $reader->nodeType == 1 && !$isAtom) {
                                                 $isInItem = 1;
                                                 $itemNumber++;
                                                 $item = array();
                                             } else {
                                                 if (in_array("{$name}", $this->itemElements) && $reader->nodeType == 1 && $isInItem && !$isAtom) {
                                                     $reader->read();
                                                     $item["{$name}"] = $reader->value;
                                                 } else {
                                                     if ($name == "description" && $reader->nodeType == 1 && $isInItem && !$isAtom) {
                                                         $isInDescription = 1;
                                                         $reader->read();
                                                         $description = $reader->value;
                                                         if ($this->strip) {
                                                             $newDescription = preg_replace("/<.+?>/", "", $description);
                                                         } else {
                                                             $newDescription = $description;
                                                         }
                                                         $item["description"] = $newDescription;
                                                     } else {
                                                         if ($name == "description" && $reader->nodeType == 15) {
                                                             $isInDescription = 0;
                                                         } else {
                                                             if ($name == "enclosure" && $reader->nodeType == 1 && $isInItem && !$isAtom) {
                                                                 foreach ($this->enclosureAttributes as $enatt) {
//.........这里部分代码省略.........
开发者ID:kenirwin,项目名称:SubjectsPlus,代码行数:101,代码来源:PGFeed.php

示例12: XMLReader

$reader = new XMLReader();
$reader->XML($catalog);
// Perl Cookbook ISBN is 0596003137
// Use array to make it easy to add additional ISBNs
$isbns = array('0596003137' => true);
/* Loop through document to find first <book> */
while ($reader->read()) {
    /* If you're at an element named 'book' */
    if ($reader->nodeType == XMLREADER::ELEMENT && $reader->localName == 'book') {
        break;
    }
}
/* Loop through <book>s to find right ISBNs */
do {
    if ($reader->moveToAttribute('isbn') && isset($isbns[$reader->value])) {
        while ($reader->read()) {
            switch ($reader->nodeType) {
                case XMLREADER::ELEMENT:
                    print $reader->localName . ": ";
                    break;
                case XMLREADER::TEXT:
                    print $reader->value . "\n";
                    break;
                case XMLREADER::END_ELEMENT:
                    if ($reader->localName == 'book') {
                        break 2;
                    }
            }
        }
    }
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:30,代码来源:parse-xml8.php

示例13: moveToAttribute

 public function moveToAttribute($name)
 {
     return parent::moveToAttribute($name);
 }
开发者ID:philip,项目名称:phd,代码行数:4,代码来源:Reader.php


注:本文中的XMLReader::moveToAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。