本文整理汇总了PHP中XMLParser::Parse方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::Parse方法的具体用法?PHP XMLParser::Parse怎么用?PHP XMLParser::Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::Parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __update_cache
/**
* Update currency cache
*/
private function __update_cache($force = False)
{
if (!is_null($this->_cache) && !$force) {
return;
}
$filename = $this->path . 'data/iso_currencies.xml';
if (file_exists($filename)) {
// get XML file
$data = file_get_contents($filename);
$xml = new XMLParser($data, $filename);
$xml->Parse();
$currencies = array();
// create list with unique data
foreach ($xml->document->tagChildren as $iso_currency) {
// extract data
$entity = $iso_currency->tagChildren[0]->tagData;
$currency = $iso_currency->tagChildren[1]->tagData;
$alphabetic_code = $iso_currency->tagChildren[2]->tagData;
$numeric_code = $iso_currency->tagChildren[3]->tagData;
$minor_unit = $iso_currency->tagChildren[4]->tagData;
if ($numeric_code == '' || $alphabetic_code == 'XXX') {
continue;
}
$currencies[] = array('entity' => $entity, 'currency' => $currency, 'alphabetic_code' => $alphabetic_code, 'numeric_code' => $numeric_code, 'minor_unit' => $minor_unit);
// update cache
$this->_cache = $currencies;
}
}
}
示例2: entity
function thor_build_display_values()
{
$form = new entity($this->form_id);
$form->get_values();
if ($form->get_value('type') != id_of('form'))
{
trigger_error('the thor viewer was passed an invalid id ('.$form_id.') - it must be passed the ID of a reason form entity');
}
else
{
$form_xml_obj = new XMLParser($form->get_value('thor_content'));
$form_xml_obj->Parse();
$display_values = array();
foreach ($form_xml_obj->document->tagChildren as $k=>$v)
{
$tagname = is_object($v) ? $v->tagName : '';
if (method_exists($this, '_build_display_'.$tagname))
{
$build_function = '_build_display_'.$tagname;
$display_values = array_merge($display_values, $this->$build_function($v));
}
}
}
foreach ($this->extra_fields as $field_name)
{
$display_values[$field_name]['label'] = prettify_string($field_name);
$display_values[$field_name]['type'] = 'text';
}
$this->_display_values = (isset($display_values)) ? $display_values : array();
}
示例3: testXml
/**
* 测试XML解析类
*/
function testXml()
{
$xml = file_get_contents('temp.xml');
$this->load->library('XMLParserLib');
$parser = new XMLParser($xml);
$parser->Parse();
print_r($parser->document->globalinfo);
//echo $parser->GenerateXML();
}
示例4: loadModules
/**
* Load all modules in specified path
*
* @param boolean $include_only
*/
function loadModules($include_only = false)
{
global $db_use, $data_path;
$preload_list = array();
$normal_list = array();
if ($db_use) {
// database available, form module list from database entries
$manager = ModuleManager::getInstance();
// get priority module list
$preload_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 1), array('order'));
// get normal module list
$normal_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 0), array('order'));
foreach ($preload_raw as $preload_item) {
$preload_list[] = $preload_item->name;
}
foreach ($normal_raw as $normal_item) {
$normal_list[] = $normal_item->name;
}
} else {
// no database available use system initialization file
$file = $data_path . 'system_init.xml';
if (file_exists($file)) {
$xml = new XMLParser(@file_get_contents($file), $file);
$xml->Parse();
foreach ($xml->document->tagChildren as $xml_tag) {
if ($xml_tag->tagName == 'module') {
$normal_list[] = $xml_tag->tagAttrs['name'];
}
}
}
}
// load modules
if (count($preload_list) > 0) {
foreach ($preload_list as $module_name) {
$this->_loadModule($module_name);
}
}
if (count($normal_list) > 0) {
if ($include_only) {
foreach ($normal_list as $module_name) {
$this->_includeModule($module_name);
}
} else {
foreach ($normal_list as $module_name) {
$this->_loadModule($module_name);
}
}
}
}
示例5: get_links_from_rss_string
function get_links_from_rss_string($rss)
{
require_once INCLUDE_PATH . 'xml/xmlparser.php';
$xml_parse = new XMLParser($rss);
$xml_parse->Parse();
$links = array();
if (isset($xml_parse->document->channel[0]->item)) {
foreach ($xml_parse->document->channel[0]->item as $k => $item) {
if (isset($item->link[0]->tagData)) {
$links[] = trim(str_replace('&', '&', $item->link[0]->tagData));
}
}
}
return $links;
}
示例6: __construct
/**
* Constructor
*
* @return LanguageHandler
*/
public function __construct($file = '')
{
global $data_path;
$this->active = false;
$file = empty($file) ? $data_path . 'system_language.xml' : $file;
// make sure language file exists
if (!file_exists($file)) {
return;
}
// parse language file
$engine = new XMLParser(@file_get_contents($file), $file);
$engine->Parse();
$this->active = true;
// make sure language file is not empty
if (!isset($engine->document) || !isset($engine->document->language)) {
return;
}
foreach ($engine->document->language as $xml_language) {
$short_name = $xml_language->tagAttrs['short'];
$full_name = isset($xml_language->tagAttrs['name']) ? $xml_language->tagAttrs['name'] : '';
$is_rtl = isset($xml_language->tagAttrs['rtl']) && $xml_language->tagAttrs['rtl'] == 'yes';
$default = isset($xml_language->tagAttrs['default']);
// add to language list
$this->languages[$short_name] = $full_name;
// create storage for constants
$this->data[$short_name] = array();
// mark as RTL
if ($is_rtl) {
$this->rtl_languages[] = $short_name;
}
// set as default
if (is_null($this->default) && $default) {
$this->default = $short_name;
}
// parse language constants
foreach ($xml_language->constant as $xml_constant) {
$constant_name = $xml_constant->tagAttrs['name'];
$value = $xml_constant->tagData;
$this->data[$short_name][$constant_name] = $value;
}
}
// remove parser
unset($engine);
}
示例7: strtolower
} else {
$args .= '&mainSearchCriteria.v.c=' . strtolower($_SESSION['web_search_q']);
}
}
break;
}
//********************************************************************************
// build the URL using the baseUrl and the appended arguments from the if/else
//********************************************************************************
$url = $baseUrl . $args;
//********************************************************************************
// XML parser... PFM!
//********************************************************************************
$xml = file_get_contents($url);
$parser = new XMLParser($xml);
$parser->Parse();
$rows = array();
//--------------------------------------------------------------------------------
// get the total value form the xml
//--------------------------------------------------------------------------------
switch ($_SESSION['search_type']) {
case 'health_topics':
if (isset($parser->document->list[0]->document)) {
$totals = $parser->document->count[0]->tagData;
//----------------------------------------------------------------------------
// store file value for pager, if need it
//----------------------------------------------------------------------------
$_SESSION['web_search_file'] = $parser->document->file[0]->tagData;
//****************************************************************************
// now lets work the xml file to push stuff into the $rows array()
//****************************************************************************
示例8: entity
/**
* Returns an existing or new XML_Parser object for the thor content of a reason form.
* @param reason form id
* @return object XML_Parser
*/
function &getXMLParser()
{
static $xml_parsers;
$id = $this->get_table_id();
if (isset($xml_parsers[$id])) return $xml_parsers[$id];
else
{
$table_entity = new entity($id);
$table_xml = $table_entity->get_value('thor_content');
$xml_parser = new XMLParser($table_xml);
$xml_parser->Parse();
$xml_parsers[$id] =& $xml_parser;
}
return $this->getXMLParser();
}
示例9: ipl_core_load_xml
/**
* Load the data from the response as xml
*
*/
function ipl_core_load_xml($xmlDataString)
{
global $ipl_core_error_code;
global $ipl_core_error_msg;
global $ipl_core_api_error_code;
global $ipl_core_api_customer_message;
global $ipl_core_api_merchant_message;
switch (IPL_CORE_XML_PARSER) {
case 'simpleXml':
if (!function_exists('simplexml_load_string')) {
$ipl_core_error_code = 15;
$ipl_core_error_msg = 'simpleXml lib has not been loaded';
return false;
}
$xml = simplexml_load_string($xmlDataString);
if (!$xml) {
$ipl_core_error_code = 10;
$ipl_core_error_msg = 'Invalid XML reponse received';
return false;
} else {
$attr = $xml->attributes();
$ipl_core_api_error_code = (int) $attr->error_code;
$ipl_core_api_customer_message = (string) $attr->customer_message;
$ipl_core_api_merchant_message = (string) $attr->merchant_message;
}
break;
case 'preg':
$errorCode = ipl_core_get_xml_attribute_value('data', 'error_code', $xml);
if ($errorCode === false) {
return false;
}
if ($errorCode > 0) {
$ipl_core_api_customer_message = ipl_core_get_xml_attribute_value('data', 'customer_message', $xml);
$ipl_core_api_merchant_message = ipl_core_get_xml_attribute_value('data', 'merchant_message', $xml);
}
break;
case 'xmlParser':
$parser = new XMLParser($xmlDataString);
if ($parser->Parse() == false) {
$xmlError = $parser->getError();
$ipl_core_error_code = 10;
$ipl_core_error_msg = "Invalid XML reponse received: {$xmlError}";
return false;
}
$xml = $parser->document;
if (!$xml) {
$ipl_core_error_code = 10;
$ipl_core_error_msg = 'Invalid XML reponse received';
return false;
} else {
$ipl_core_api_error_code = (int) $xml->tagAttrs['error_code'];
$ipl_core_api_customer_message = ipl_core_decode((string) $xml->tagAttrs['customer_message']);
$ipl_core_api_merchant_message = ipl_core_decode((string) $xml->tagAttrs['merchant_message']);
}
break;
default:
$ipl_core_error_code = 9;
$ipl_core_error_msg = 'Unknown XML parser lib: ' . IPL_CORE_XML_PARSER;
return false;
break;
}
return $xml;
}
示例10: array
function _ResponseResultToResponseArray($SomeResult)
{
$this->responsearray = array();
if (empty($SomeResult)) {
// $SomeArray
// we have an error
$this->responsearray['status'] = 'Error';
$this->responsearray['statusCode'] = '500';
$this->responsearray['errorDescription'] = 'No Response';
return;
}
//echo '<br>$this->ContentType='.$this->ContentType.'<br>';
if ($this->ContentType != 'JSON' && $this->ContentType != 'PHPSERIAL' && $this->ContentType != 'XML') {
$this->ContentType = 'JSON';
}
//echo '<br>$this->ContentType='.$this->ContentType.'<br>';
if ($this->ContentType == 'JSON') {
if (class_exists('Services_JSON')) {
//$JSONObj = new Services_JSON();
//return $JSONObj->encode($SomeArray);
$JSONObj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
$this->responsearray = $JSONObj->decode($SomeResult);
} else {
// throw error
trigger_error("ERROR: Services_JSON class not available", E_USER_ERROR);
}
} else {
if ($this->ContentType == 'XML') {
if (class_exists('XMLParser')) {
$parser = new XMLParser($SomeResult, false, false);
$parser->Parse();
$this->responsearray = $parser->ReturnArray();
$this->responsearray = $this->responsearray['root'];
// this forces the 'results' response to always have a child 0, xml can omit this
if (isset($this->responsearray['results']) && is_array($this->responsearray['results']) && !isset($this->responsearray['results']['0']) && count($this->responsearray['results'] > 0)) {
$temparray = $this->responsearray['results'];
unset($this->responsearray['results']);
$this->responsearray['results']['0'] = $temparray;
unset($temparray);
}
//$XMLObj = new ArrayXML( $SomeArray );
//return '<'.'?'.'xml version="1.0" encoding="UTF-8" ?'.'>'."\n".'<root>'."\n".$XMLObj->ReturnXML().'</root>';
} else {
// throw error
trigger_error("ERROR: XMLParser class not available", E_USER_ERROR);
}
} else {
if ($this->ContentType == 'PHPSERIAL') {
//return serialize($SomeArray);
$this->responsearray = unserialize($SomeResult);
//if ( is_array( $this->xmlarray ) )
//{
// $this->xmlarray['root'] = array_changekeycase_r( $this->xmlarray['root'], CASE_LOWER );
//}
}
}
}
if (!empty($this->responsearray['status'])) {
$this->Status = $this->responsearray['status'];
}
if (!empty($this->responsearray['statusCode'])) {
$this->StatusCode = $this->responsearray['statusCode'];
}
if (!empty($this->responsearray['errorDescription'])) {
$this->ErrorDescription = $this->responsearray['errorDescription'];
}
// $this->responsearray['status'] = 'Success'
// $this->responsearray['statusCode'] = '200'
//}
// default
//$JSONObj = new Services_JSON();
//return $JSONObj->encode($SomeArray);
}
示例11: _legacy_get_db_credentials
/**
* Return authentication credentials for the specified database connection.
*
* @param string $conn_name The name of the db connection you want to retrieve
* @param boolean $lack_of_creds_is_fatal defaults to true for historical purposes
* @return array Array with all the db connection info defined for the specified named connection.
*/
function _legacy_get_db_credentials($conn_name, $lack_of_creds_is_fatal = true)
{
static $db_info;
// if db_info has not been set, this is the first time this function has been run.
if (!isset($db_info)) {
trigger_warning('Using _legacy_get_db_credentials - please upgrade to PHP 5.1 or later to use faster XML functions.');
if (!defined('DB_CREDENTIALS_FILEPATH')) {
trigger_fatal_error('The DB_CREDENTIALS_FILEPATH constant is not defined.');
}
$db_info = array();
require_once INCLUDE_PATH . 'xml/xmlparser.php';
if (file_exists(DB_CREDENTIALS_FILEPATH) && ($xml = trim(file_get_contents(DB_CREDENTIALS_FILEPATH)))) {
$xml_parse = new XMLParser($xml);
$parse = $xml_parse->Parse();
if (isset($xml_parse->document->database)) {
foreach ($xml_parse->document->database as $database) {
$tmp = array();
$db_conn_name = isset($database->connection_name[0]->tagData) ? $database->connection_name[0]->tagData : false;
$tmp['db'] = isset($database->db[0]->tagData) ? $database->db[0]->tagData : false;
$tmp['user'] = isset($database->user[0]->tagData) ? $database->user[0]->tagData : false;
$tmp['password'] = isset($database->password[0]->tagData) ? $database->password[0]->tagData : false;
$tmp['host'] = isset($database->host[0]->tagData) ? $database->host[0]->tagData : false;
if ($db_conn_name && $tmp['db'] !== false && $tmp['user'] !== false && $tmp['password'] !== false && $tmp['host'] !== false) {
$db_info[$db_conn_name] = $tmp;
} else {
$invalid_entries[] = $db_conn_name;
}
}
}
if (isset($invalid_entries)) {
$invalid_str = $invalid_entries == 1 ? $invalid_entries . ' entry appears' : $invalid_entries . ' entries appear';
turn_carl_util_error_context_off();
foreach ($invalid_entries as $conn_name) {
if (!empty($conn_name)) {
trigger_error('The connection ' . $conn_name . ' in the db credentials XML file (' . DB_CREDENTIALS_FILEPATH . ') appears to have missing or invalid values.', WARNING);
} else {
trigger_error('An entry without a connection name is defined in the db credentials XML file (' . DB_CREDENTIALS_FILEPATH . ')', WARNING);
}
}
turn_carl_util_error_context_on();
}
if (empty($db_info)) {
trigger_error('Check the xml in the db credentials XML file (' . DB_CREDENTIALS_FILEPATH . ') - no valid database connection information could be built.', WARNING);
}
} else {
trigger_fatal_error('The DB_CREDENTIALS_FILEPATH (' . DB_CREDENTIALS_FILEPATH . ') refers to a file that is missing or does not have any content.');
}
}
// if this was the first time, the code above should have run successfully so db_info is populated.
// if this is not the first time, then the code above should have been skipped since it was populated the first
// run of the function.
if (isset($db_info[$conn_name])) {
return $db_info[$conn_name];
} else {
// disable context display so we do not show passwords on screen.
turn_carl_util_error_context_off();
if ($lack_of_creds_is_fatal) {
trigger_fatal_error('Unable to use database connection ' . $conn_name . ' - No credential information found for the connection named ' . $conn_name . ' in database credential file (' . DB_CREDENTIALS_FILEPATH . ').', 2);
} else {
trigger_warning('Unable to use database connection ' . $conn_name . ' - No credential information found for the connection named ' . $conn_name . ' in database credential file (' . DB_CREDENTIALS_FILEPATH . ').', 2);
}
turn_carl_util_error_context_on();
}
return false;
}
示例12: XMLParser
function get_file_upload_summary_data()
{
$rawXml = $this->get_form_entity()->get_value('thor_content');
$formXml = new XMLParser($rawXml);
$formXml->Parse();
$attachmentData = array();
foreach ($formXml->document->tagChildren as $node) {
if ($node->tagName == 'upload') {
$col_id = $node->tagAttrs['id'];
$col_label = $node->tagAttrs['label'];
$upload_data = $_FILES[$col_id];
if ($upload_data["tmp_name"] != "") {
$disco_el = $this->get_view()->get_element($col_id);
if ($disco_el->state == "received") {
$attachmentData[$col_id] = array("label" => $col_label, "filename" => $upload_data["name"]);
if ($this->should_save_form_data()) {
$tc = $this->get_thor_core_object();
$attachmentData[$col_id]["path"] = $tc->construct_file_storage_location($this->get_form_id(), $col_id, $upload_data["name"]);
} else {
$attachmentData[$col_id]["path"] = $disco_el->tmp_full_path;
}
}
}
}
}
return $attachmentData;
}
示例13: __construct
foreach (FoxydataUtils::$CustomerAddressFieldMap as $feed_field => $db_field) {
$rtn[$prefix . $db_field] = $address_fields[$feed_field];
}
$country = $this->osc->findCountryByCode($address_fields['country']);
$rtn[$prefix . 'country_id'] = $country['countries_id'];
$zone = $this->osc->findZoneByNameAndCountryID($address_fields['state'], $rtn[$prefix . 'country_id']);
$rtn[$prefix . 'zone_id'] = $zone['zone_id'];
return $rtn;
}
}
$utils = new FoxydataUtils($osc);
$decryptor = new rc4crypt();
$FoxyData = $decryptor->decrypt(DATAFEED_KEY, urldecode($_POST["FoxyData"]));
$data = new XMLParser($FoxyData);
// Parse that XML.
$data->Parse();
/**
* Wrapper class to make retrieving name / value pairs from an XML feed much
* more concise. Create with an XMLTag (the result of parsing an XML
* file), then retrieve properties with, e.g., $wrapper->customers_email_address.
*/
class PropertyWrapper
{
public function __construct(XMLTag $data)
{
$this->data = $data;
}
public function __get($field)
{
$rtn = '';
if (isset($this->data->{$field})) {
示例14: getXmlDoc
private static function getXmlDoc($path)
{
if (file_exists($path)) {
$xml = file_get_contents($path);
$xmlParser = new XMLParser($xml);
$xmlParser->Parse();
return $xmlParser;
} else {
throw new MashapeException(sprintf(EXCEPTION_CONFIGURATION_FILE_NOTFOUND, $path), EXCEPTION_XML_CODE);
}
}
示例15: verify_mysql
function verify_mysql($db_conn_name, $constant_name, $constant_location, $check_for_tables = false)
{
include_once INCLUDE_PATH . 'xml/xmlparser.php';
// we have verified this exists already
$db_file = DB_CREDENTIALS_FILEPATH;
// we have verified this exists
$xml = file_get_contents($db_file);
if (!empty($xml)) {
$xml_parse = new XMLParser($xml);
$xml_parse->Parse();
foreach ($xml_parse->document->database as $database) {
$tmp = array();
$tmp['db'] = $database->db[0]->tagData;
$tmp['user'] = $database->user[0]->tagData;
$tmp['password'] = $database->password[0]->tagData;
$tmp['host'] = $database->host[0]->tagData;
$db_info_all[$database->connection_name[0]->tagData] = $tmp;
}
} else {
return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - the db connection xml file does not appear to have any contents', false);
}
$db_info = isset($db_info_all[$db_conn_name]) ? $db_info_all[$db_conn_name] : false;
if ($db_info === false) {
return msg('mysql check failed - ' . $db_conn_name . ' is an invalid connection name.
<p>Make sure the constant ' . $constant_name . ' in ' . $constant_location . ' maps to the connection name in your db connection xml file</p>', false);
}
if (empty($db_info['db']) || empty($db_info['user']) || empty($db_info['password']) || empty($db_info['host'])) {
return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - the db connection xml file for does not have full information for the connection named ' . $db_conn_name . '.
<p>Check the constant ' . $constant_name . ' in ' . $constant_location . ' to make sure it matches the connection name in your db connection xml file.</p>', false);
}
$db = mysql_connect($db_info['host'], $db_info['user'], $db_info['password']);
if (empty($db)) {
return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - count not connect to server - could be one of the following
<ul>
<li>Improper username and/or password in the db credentials file</li>
<li>Improper mysql hostname - currently set to ' . $db_info['host'] . '</li>
<li>The user ' . $db_info['user'] . ' needs to have been granted permission to connect to ' . $db_info['host'] . ' from the web server</li>
</ul>', false);
} else {
if (!mysql_select_db($db_info['db'], $db)) {
return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> - connected to host as user ' . $db_info['user'] . ' but could not select database ' . $db_info['db'] . '. Check the db credential xml file and user privileges', false);
}
}
// check_for_tables
if ($check_for_tables) {
$result = db_query('show tables');
$table_count = mysql_num_rows($result);
if ($table_count == 0) {
return msg('<span class="error">mysql connection ' . $db_conn_name . ' check failed</span> -
The database ' . $db_info['db'] . ' does not appear to have any tables.<p><a href="./install.htm#database_setup">Consult the reason install documentation</a>
for information on how to import the reason database.</p>', false);
}
}
return msg('<span class="success">mysql connection ' . $constant_name . '(' . $db_conn_name . ') check passed</span>', true);
}