本文整理汇总了PHP中XMLParser::getElement方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::getElement方法的具体用法?PHP XMLParser::getElement怎么用?PHP XMLParser::getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::getElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createArticles
/**
* Creates articles for the terms according to the mapping and conflict policy.
*
* @param string $terms
* This XML string contains all terms that the DAL delivered
* @param string $mappingPolicy
* This XML string contains the name of an article that is a template
* for the articles that will be created.
* @param string $conflictPolicy
* This XML string specifies, if existing articles will be overwritten.
* @parameter IWil $wil
* The wiki import layer object
* @return mixed (boolean, string)
* <true>, if all terms were successfully imported or an
* error message, otherwise.
*
*/
private function createArticles($terms, $mappingPolicy, $conflictPolicy, $wil, $termImportName)
{
global $smwgDIIP;
require_once $smwgDIIP . '/specials/TermImport/SMW_XMLParser.php';
echo "\nStart to create articles";
$log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
$parser = new XMLParser($mappingPolicy);
$result = $parser->parse();
if ($result !== TRUE) {
return $result;
}
$mp = $parser->getValuesOfElement(array('MappingPolicy', 'page'));
if (!is_array($mp) || !$mp[0]) {
return wfMsg('smw_ti_missing_mp');
}
$mp = $mp[0];
// get the content of the article that contains the mapping policy
$mp = strip_tags($mp);
if ($mp == '') {
return wfMsg('smw_ti_missing_mp', $mp);
}
$mp = Title::newFromText($mp);
$mp = new Article($mp);
$mp = $mp->getContent();
$parser = new XMLParser($conflictPolicy);
$result = $parser->parse();
if ($result !== TRUE) {
return $result;
}
$cp = $parser->getValuesOfElement(array('ConflictPolicy', 'overwriteExistingTerms'));
$cp = $cp[0];
$cp = strtolower($cp) == 'true' ? true : false;
//echo("\n\n".$terms."\n\n");
//$file = fopen("d:/result.txt", w);
//fwrite($file, $terms);
//fclose($file);
//echo("\n\n".$terms."\n\n");
echo "\nCreate xml parser";
try {
$parser = new SimpleXMLElement($terms, LIBXML_NOCDATA);
} catch (Exception $e) {
return "The XML parser could not be created because: " . $e;
}
if (!key_exists("term", $parser)) {
foreach ($parser->errors as $errors) {
foreach ($errors->error as $error) {
$this->importErrors[] = $error[0];
}
}
return wfMsg('smw_ti_import_successful');
}
$numTerms = count($parser->term);
echo "\nNumber of terms: " . $numTerms . "\n";
$this->setNumberOfTasks(1);
$this->addSubTask($numTerms);
$timeInTitle = $this->getDateString();
$termImportName = "TermImport:" . $termImportName . "/" . $timeInTitle;
$noErrors = true;
foreach ($parser->term as $term) {
//check if this is a callback term
if ($term['callback']) {
$callBackResult = $wil->executeCallBack("" . $term, $mp, $cp, $termImportName);
$cBRParser = new XMLParser($callBackResult);
$cBRParser->parse();
$nextId = 0;
$nextTitle = 0;
while ($logMsg = $cBRParser->getElement(array('logMessage', 'id'), $nextId)) {
$titleName = $cBRParser->getElement(array('logMessage', 'title'), $nextTitle);
$log->addGardeningIssueAboutArticle($this->id, $logMsg['ID'][0]['value'], Title::newFromText($titleName['TITLE'][0]['value']));
}
$nextSuccess = 0;
$callBackSucces = $cBRParser->getElement(array('success'), $nextSuccess);
if ($callBackSucces['SUCCESS'][0]['value'] == 'false') {
//todo: allow callbacks to return eror messages
$noErrors = false;
}
$this->worked(1);
continue;
}
$caResult = $this->createArticle($term, $mp, $cp, $termImportName);
$this->worked(1);
if ($caResult !== true) {
$noErrors = false;
//.........这里部分代码省略.........
示例2: getTLIDs
public function getTLIDs($tlModules)
{
global $smwgDIIP;
require_once $smwgDIIP . '/specials/TermImport/SMW_XMLParser.php';
$p = new XMLParser($tlModules);
$result = $p->parse();
if ($result == TRUE) {
$tlmodules = $p->getElement(array('TLModules'));
$count = count($tlmodules['TLMODULES'][0]['value']['MODULE']);
for ($i = 0; $i < $count; $i++) {
$tlid = $tlmodules['TLMODULES'][0]['value']['MODULE'][$i]['value']['ID'][0]['value'];
$html = "<div class=\"entry\" onMouseOver=\"this.className='entry-over';\"" . " onMouseOut=\"termImportPage.showRightTLM(event, this, '{$tlid}')\" onClick=\"termImportPage.connectTL(event, this, '{$tlid}')\">" . "<a>" . $tlid . "</a>" . "</div>";
}
}
return $html;
}