本文整理汇总了PHP中XMLParser::getValuesOfElement方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::getValuesOfElement方法的具体用法?PHP XMLParser::getValuesOfElement怎么用?PHP XMLParser::getValuesOfElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::getValuesOfElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: parseInputPolicy
/**
* Parses the input policy in the XML string <$inputPolicy>. The policy
* specifies concrete terms, regular expression for terms to import and
* the properties of the terms to import.
*
* @param string $inputPolicy
* An XML string that contains the input policy.
* @return array(array<string>)
* An array with three arrays (keys: "terms", "regex", "properties")
* that contain the values from the XML string or an error message
* if the XML is not valid.
*/
private function parseInputPolicy(&$inputPolicy)
{
global $smwgDIIP;
require_once $smwgDIIP . '/specials/TermImport/SMW_XMLParser.php';
$parser = new XMLParser($inputPolicy);
$result = $parser->parse();
if ($result !== TRUE) {
return $result;
}
$policy = array();
$policy['terms'] = $parser->getValuesOfElement(array('terms', 'term'));
$policy['regex'] = $parser->getValuesOfElement(array('terms', 'regex'));
$policy['properties'] = $parser->getValuesOfElement(array('properties', 'property'));
return $policy;
}
示例3: parseImportSets
private function parseImportSets(&$importSets)
{
global $smwgDIIP;
require_once $smwgDIIP . '/specials/TermImport/SMW_XMLParser.php';
$parser = new XMLParser($importSets);
$result = $parser->parse();
if ($result !== TRUE) {
return $result;
}
return $parser->getValuesOfElement(array('importSet', 'name'));
}