本文整理汇总了PHP中xml类的典型用法代码示例。如果您正苦于以下问题:PHP xml类的具体用法?PHP xml怎么用?PHP xml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了xml类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getFormElement
function getFormElement($id)
{
if ($e = $this->query('form' . ($id ? '[@id="' . $id . '"]' : null))->item(0)) {
$xml = new xml(null, null, false);
return $xml->appendChild($xml->importNode($e));
}
}
开发者ID:PapaKot,项目名称:Horowitz,代码行数:7,代码来源:apModule.php
示例2: settings
function settings($action)
{
global $_out, $_struct;
if (($xml = $this->getDataXML()) && ($e = $xml->getElementById('settings'))) {
$form = new form($e);
$form->replaceURI(array('MODULE' => $this->getId(), 'SECTION' => $this->getSection()->getId(), 'PATH_DATA_FILE_CLIENT' => ABS_PATH_DATA_CLIENT . ap::id($this->getSection()->getId()) . '.xml', 'PATH_DATA_FILE_AP' => ABS_PATH_DATA_AP . ap::id($this->getSection()->getId()) . '.xml'));
if ($ff = $form->getField('section')) {
apSectionEdit::seclist(ap::getClientstructure()->de(), $ff, $ar = array());
}
switch ($action) {
case 'update':
case 'apply_update':
$form->save($_REQUEST);
break;
case 'edit':
if (($id = param('section')) && ($sec = $_struct->getSection($id)) && ($modules = $sec->getModules())) {
$xml = new xml(null, 'modules', false);
foreach ($modules as $m) {
$xml->de()->appendChild($xml->importNode($m->getRootElement(), false));
}
ap::ajaxResponse($xml);
}
break;
}
$form->load();
$_out->addSectionContent($form->getRootElement());
$this->addTemplate('tpl.xsl');
}
}
开发者ID:PapaKot,项目名称:Horowitz,代码行数:29,代码来源:apAnnounce.php
示例3: query
function query($args, $document)
{
$this->validate($args);
$sql = $this->datasource->get();
$xml = new xml();
$this->single() or $sql->begin();
$n = 0;
foreach ($this->body as $query) {
if ($rows = $sql->query($this->apply($query, $args))) {
$root = $xml->element($this->root[$n]);
$xml->append($root);
foreach ($rows as $row) {
$item = $xml->element($this->item[$n]);
$root->append($item);
foreach ($row as $name => $value) {
$node = $this->transform($xml, $name, $value);
$item->append($node);
}
}
++$n;
}
}
if (!$this->empty && $xml->blank()) {
$this->single() or $sql->rollback();
runtime_error('SQL procedure returned empty result: ' . $this->mangled());
} else {
$this->single() or $sql->commit();
}
return $document ? $xml : $xml->evaluate('/*[position() = 1]/*[position() = 1]/*[position() = 1]/text()');
}
开发者ID:nyan-cat,项目名称:easyweb,代码行数:30,代码来源:sql_procedure.php
示例4: XML_unserialize
function XML_unserialize($xml)
{
$xml_parser = new xml();
$data = $xml_parser->parse($xml);
$xml_parser->destruct();
return $data;
}
开发者ID:yunsite,项目名称:tp-coupon,代码行数:7,代码来源:Xml.class.php
示例5: run
function run()
{
global $_out, $_sec;
if (ap::isCurrentModule($this)) {
ap::addMessage($this->getMessage());
if ($form = $this->getForm()) {
$form->replaceURI(array('ID' => $_sec->getId(), 'MD' => $this->getId(), 'PARENT' => $this->getSection()->GetParent()->getId()));
switch ($action = param('action')) {
case 'save':
$values = $this->initImages($form, true);
$values = array_merge($_REQUEST, $values);
$form->save($values);
$this->updateImagesSize($form);
$this->redirect('save_ok');
break;
case 'fileinfo':
if (($path = urldecode(param('path'))) && ($f = ap::getFileInfo($_SERVER['DOCUMENT_ROOT'] . $path))) {
$f['path'] = $path;
$xml = new xml(null, 'file', false);
foreach ($f as $tagName => $value) {
$xml->de()->appendChild($xml->createElement($tagName, null, $value));
}
ap::ajaxResponse($xml);
}
vdump('Error file not found ' . $path);
break;
}
$this->initImages($form, false);
$form->load();
$_out->elementIncludeTo($form->getRootElement(), '/page/section');
} else {
throw new Exception('Form not found', EXCEPTION_XML);
}
}
}
开发者ID:PapaKot,项目名称:Horowitz,代码行数:35,代码来源:apContent.php
示例6: xml
function xml()
{
$xml = new xml();
foreach ($this->children as $child) {
$xml->append(self::node($xml, $child));
}
return $xml;
}
开发者ID:nyan-cat,项目名称:easyweb,代码行数:8,代码来源:xtree.php
示例7: getSiteInfo
function getSiteInfo()
{
$xml = new xml();
$xml->dd()->appendChild($xml->importNode($this->de()));
$ns = $xml->query('/site/mysql | /site/users');
foreach ($ns as $n) {
$n->parentNode->removeChild($n);
}
return $xml;
}
开发者ID:PapaKot,项目名称:Horowitz,代码行数:10,代码来源:site.php
示例8: get
function get($alias)
{
$alias .= ':' . $this->language;
if (isset($this->local[$alias])) {
return $this->local[$alias]->xml();
} else {
$xml = new xml();
$xml->append($xml->text("[Alias not found: {$alias}]"));
return $xml;
}
}
开发者ID:nyan-cat,项目名称:easyweb,代码行数:11,代码来源:locale.php
示例9: install
function install()
{
$xml_data = new xml(PATH_MODULE . $this->getName() . '/data.xml');
$xml_sec = $this->getSection()->getXML();
$ar = array('form_edit', 'form_add', 'banner_list');
foreach ($ar as $id) {
if (($e = $xml_data->query('//*[@id="' . $id . '"]')->item(0)) && !$xml_sec->evaluate('count(./*[@id="' . $id . '"])', $this->getRootElement())) {
$xml_sec->elementIncludeTo($e, $this->getRootElement());
}
}
$xml_sec->save();
return true;
}
开发者ID:PapaKot,项目名称:Horowitz,代码行数:13,代码来源:apBanners.php
示例10: __construct
function __construct(xml $xml, $tagName = null)
{
global $_struct;
if (!$tagName) {
$tagName = 'modules';
}
if ($modules = $xml->query($query = '/*/' . $tagName)->item(0)) {
} else {
$modules = $xml->de()->appendChild($xml->createElement($tagName));
}
parent::__construct($modules, 'module');
$this->keyAttribute = 'id';
$this->setStructure($_struct);
}
开发者ID:PapaKot,项目名称:Horowitz,代码行数:14,代码来源:modules.php
示例11: action_edit_field
public function action_edit_field()
{
$field_id = $this->request->param('options');
xml::to_XML(array('field' => array('@id' => $field_id, '$content' => User::get_data_field_name($field_id))), $this->xml_content);
if (count($_POST) && isset($_POST['field_name'])) {
$post = new Validation($_POST);
$post->filter('trim');
$post->rule('Valid::not_empty', 'field_name');
if ($post->validate()) {
$post_values = $post->as_array();
if ($post_values['field_name'] != User::get_data_field_name($field_id) && !User::field_name_available($post_values['field_name'])) {
$post->add_error('field_name', 'User::field_name_available');
}
}
// Retry
if ($post->validate()) {
$post_values = $post->as_array();
User::update_field($field_id, $post_values['field_name']);
$this->add_message('Field ' . $post_values['field_name'] . ' updated');
$this->set_formdata(array('field_name' => $post_values['field_name']));
} else {
$this->add_error('Fix errors and try again');
$this->add_form_errors($post->errors());
$this->set_formdata(array_intersect_key($post->as_array(), $_POST));
}
} else {
$this->set_formdata(array('field_name' => User::get_data_field_name($field_id)));
}
}
开发者ID:rockymontana,项目名称:kohana-module-pajas,代码行数:29,代码来源:fields.php
示例12: parse_childnodes
public static function parse_childnodes($element)
{
$tree = array();
// Loop Child nodes
foreach ($element->childNodes as $item) {
// Text Nodes
if ($item->nodeName == '#text') {
// Only Add Ones that are not empty
if (!empty($item->nodeValue) and !preg_match('/^([ \\t\\n\\r]+)$/', $item->nodeValue)) {
$tree[] = array('type' => 'text', 'value' => $item->nodeValue);
}
} else {
$i = array('type' => 'node', 'name' => $item->nodeName, 'value' => $item->nodeValue);
// Node Children
if (!empty($item->childNodes)) {
$x = xml::parse_childnodes($item);
if (!empty($x)) {
$i['children'] = $x;
}
}
$a = array();
// Node Attributes
if (!empty($item->attributes)) {
foreach ($item->attributes as $attr) {
$a[$attr->name] = $attr->value;
}
}
if (!empty($a)) {
$i['attributes'] = $a;
}
$tree[] = $i;
}
}
return $tree;
}
开发者ID:reang,项目名称:Dingo-Framework,代码行数:35,代码来源:xml.php
示例13: view
public function view() {
global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
$diff = $wgRequest->getVal( 'diff' );
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
if ( $this->mTitle->getNamespace() != NS_TIMEDTEXT || ( isset( $diff ) && $diffOnly ) ) {
return parent::view();
}
$titleParts = explode( '.', $this->mTitle->getDBKey() );
$srt = array_pop( $titleParts );
$lanugaeKey = array_pop( $titleParts );
$videoTitle = Title::newFromText( implode('.', $titleParts ), NS_FILE );
// Look up the language name:
$languages = Language::getTranslatedLanguageNames( 'en' );
if( isset( $languages[ $lanugaeKey ] ) ) {
$languageName = $languages[ $lanugaeKey ];
} else {
$languageName = $lanugaeKey;
}
// Set title
$wgOut->setPageTitle( wfMsg('mwe-timedtext-language-subtitles-for-clip', $languageName, $videoTitle) );
// Get the video with with a max of 600 pixel page
$wgOut->addHTML(
xml::tags( 'table', array( 'style'=> 'border:none' ),
xml::tags( 'tr', null,
xml::tags( 'td', array( 'valign' => 'top', 'width' => self::$videoWidth ), $this->getVideoHTML( $videoTitle ) ) .
xml::tags( 'td', array( 'valign' => 'top' ) , $this->getSrtHTML( $languageName ) )
)
)
);
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:35,代码来源:TimedTextPage.php
示例14: executeAction
public function executeAction($params)
{
$eslCon = freeswitch_callmanager_Driver::getESL();
try {
$responsestr = $eslCon->sendRecv('api show channels as xml')->getBody();
} catch (ESLException $e) {
if (strpos($e->getMessage(), 'Not connected')) {
echo '<div class="error">Unable to connect to the switch console. This usually means that mod_event_socket is not running, or that the password that you entered during the setup process has changed. The error message was:<br>' . $e->getMessage() . '</span>';
exit;
} else {
throw $e;
}
}
if (trim($responsestr) == '0 total.' || trim($responsestr) == '+OK' || trim($responsestr) == '<result row_count="0"/>') {
return array();
}
if (substr(trim($responsestr), 0, 4) == '-ERR') {
$this->_throwError($responsestr);
}
$channelStatus = xml::xmlstrtoarr($responsestr);
if (count($channelStatus) == 0) {
return $channelStatus;
} else {
if (isset($channelStatus['row']['uuid'])) {
return array($channelStatus['row']);
} else {
return $channelStatus['row'];
}
}
}
开发者ID:swk,项目名称:bluebox,代码行数:30,代码来源:cmgetchannellist.php
示例15: toXml
/**
* The main function for converting to an XML document.
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
*
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
* @return string XML
*/
public static function toXml($data, $rootNodeName = 'data', $xml = null)
{
// turn off compatibility mode as simple xml throws a wobbly if you don't.
if (ini_get('zend.ze1_compatibility_mode') == 1) {
ini_set('zend.ze1_compatibility_mode', 0);
}
if ($xml == null) {
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
}
// loop through the data passed in.
foreach ($data as $key => $value) {
// no numeric keys in our xml please!
if (is_numeric($key)) {
// make string key...
$key = "unknownNode_" . (string) $key;
}
// replace anything not alpha numeric
$key = preg_replace('/[^a-z]/i', '', $key);
// if there is another array found recrusively call this function
if (is_array($value)) {
$node = $xml->addChild($key);
// recrusive call.
xml::toXml($value, $rootNodeName, $node);
} else {
// add single node.
$value = htmlentities($value);
$xml->addChild($key, $value);
}
}
// pass back as string. or simple xml object if you want!
return $xml->asXML();
}
开发者ID:Hulth,项目名称:API,代码行数:41,代码来源:xml.php
示例16: IPplanIPTemplate
function IPplanIPTemplate($name, $cust = 0, $netaddr = FALSE)
{
$filename = $this->__findtemp($name, $cust, $netaddr);
if ($filename == FALSE) {
return;
}
// suppress errors when loading file
if (!($data = @file($filename))) {
$this->error = TRUE;
$this->errmsg = "Error reading template file";
if (DEBUG) {
echo $this->errmsg;
}
return;
}
$input = implode("", $data);
require_once "../xmllib.php";
$xml_parser = new xml("FIELD");
if (!$xml_parser->parser) {
$this->error = TRUE;
$this->errmsg = "Error opening XML parser";
if (DEBUG) {
echo $this->errmsg;
}
return 1;
// parser not initialized - XML probably not compiled in
}
$output = $xml_parser->parse($input);
if (!$output) {
$this->error = TRUE;
$this->errmsg = "Error parsing XML file";
if (DEBUG) {
echo $this->errmsg;
}
return 1;
// not XML format
}
// turn on line below for debugging
//echo "<pre>"; var_dump($output); echo "</pre>";
foreach ($output as $key => $value) {
$field = $value["DEFINITION"]["NAME"];
// field names must be alpha numeric with no spaces etc, else row is ignored!
if (!empty($field) and preg_match("/^[a-zA-Z0-9]+\$/", $field)) {
$this->userfld["{$field}"]["descrip"] = isset($value["DEFINITION"]["DESCRIP"]) ? $value["DEFINITION"]["DESCRIP"] : "Field: " . $field;
// selectbox?
if ($this->__selectbox($value, $field)) {
continue;
}
// checkbox?
//else if ($this->__checkbox($value, $field)) {
// continue;
//}
// use default type of character - all bogus fields are converted to character
$this->__character($value, $field);
}
}
//echo "<pre>";var_dump($this->userfld);echo "</pre>";
return;
}
开发者ID:hetznerZA,项目名称:ipplan,代码行数:59,代码来源:class.templib.php
示例17: load
function load($filename)
{
$xml = xml::load($filename);
$query = [];
foreach (self::$languages as $language) {
$query[] = "/local//{$language}";
}
foreach ($xml->query(implode('|', $query)) as $node) {
$doc = new xml();
foreach ($xml->query('* | text()', $node) as $piece) {
$doc->append($doc->import($piece));
}
$path = explode('.', str_replace('/', '.', trim($node->path(), '/')));
array_shift($path);
$this->local[implode('.', $path)] = $doc->render(false);
}
}
开发者ID:nyan-cat,项目名称:easyweb,代码行数:17,代码来源:locale.php
示例18: cpanel_ddns_SearchForHostInZoneFile
/**
* Search for a host in the DNS Zone file and return the details in an array
*
* @param xml $zoneXML
* @param string $host
* @return array
*/
function cpanel_ddns_SearchForHostInZoneFile($zoneXML, $host)
{
// Count the number of zone records
$dns_records_count = count($zoneXML->children());
// PHP < 5.3 version
/*
* Loop though the zone records until we find the one that contains the record
* we wish to update. Also locate the SOA record if exists.
*/
for ($i = 0; $i <= $dns_records_count; $i++) {
// Search for the record we want to update
if ($zoneXML->record[$i]->name == $host . '.' && $zoneXML->record[$i]->type == 'A') {
$zone_number_to_update = $i;
}
// Look for the SOA record
if ($zoneXML->record[$i]->type == 'SOA') {
$zone_number_of_SOA_record = $i;
}
}
/*
* Check if we were able to locate an SOA record and return the serial if so
*/
if (!is_null($zone_number_of_SOA_record)) {
// We were able to locate an SOA record
$SOA_record = cpanel_ddns_FetchRecordFromXMLByNumber($zoneXML, $zone_number_of_SOA_record);
// echo ' % ' . $SOA_record['serial'] . ' % ';
} else {
// We were not able to locate an SOA record for this domain.
cpanel_ddns_ErrorMessageAdd('SOA not found for this domain.');
return FALSE;
}
/*
* Were we able to locate the host record?
*/
if (!is_null($zone_number_to_update)) {
// We were able to locate an A record
$zone_record = cpanel_ddns_FetchRecordFromXMLByNumber($zoneXML, $zone_number_to_update);
// echo ' % ' . $zone_record['name'] . ' % ';
} else {
// We were not able to locate an A record for this host.
cpanel_ddns_ErrorMessageAdd('A record was not found for this host.');
return FALSE;
}
return $zone_record;
}
开发者ID:netluxe,项目名称:cpanel_ddns,代码行数:52,代码来源:functions.php
示例19: from_array
public static function from_array($array, $level = 1)
{
$xml = '';
// if ($level==1) {
// $xml .= "<array>\n";
// }
foreach ($array as $key => $value) {
$key = strtolower($key);
if (is_object($value)) {
$value = get_object_vars($value);
}
// convert object to array
if (is_array($value)) {
$multi_tags = false;
foreach ($value as $key2 => $value2) {
if (is_object($value2)) {
$value2 = get_object_vars($value2);
}
// convert object to array
if (is_array($value2)) {
$xml .= str_repeat("\t", $level) . "<{$key}>\n";
$xml .= xml::from_array($value2, $level + 1);
$xml .= str_repeat("\t", $level) . "</{$key}>\n";
$multi_tags = true;
} else {
if (trim($value2) != '') {
if (htmlspecialchars($value2) != $value2) {
$xml .= str_repeat("\t", $level) . "<{$key2}><![CDATA[{$value2}]]>" . "</{$key2}>\n";
} else {
$xml .= str_repeat("\t", $level) . "<{$key2}>{$value2}</{$key2}>\n";
// changed $key to $key2
}
}
$multi_tags = true;
}
}
if (!$multi_tags and count($value) > 0) {
$xml .= str_repeat("\t", $level) . "<{$key}>\n";
$xml .= xml::from_array($value, $level + 1);
$xml .= str_repeat("\t", $level) . "</{$key}>\n";
}
} else {
if (trim($value) != '') {
// echo "value=$value<br>";
if (htmlspecialchars($value) != $value) {
$xml .= str_repeat("\t", $level) . "<{$key}>" . "<![CDATA[{$value}]]></{$key}>\n";
} else {
$xml .= str_repeat("\t", $level) . "<{$key}>{$value}</{$key}>\n";
}
}
}
}
//if ($level==1) {
// $xml .= "</array>\n";
// }
return $xml;
}
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:57,代码来源:xml.php
示例20: list_available_data_fields
private function list_available_data_fields()
{
$fields = array();
foreach (User::get_data_fields() as $field_id => $field_name) {
$fields['field id="' . $field_id . '"'] = $field_name;
}
$this->xml_content_users = $this->xml_content->appendChild($this->dom->createElement('users'));
xml::to_XML($fields, $this->xml_content_users);
}
开发者ID:rockymontana,项目名称:kohana-module-pajas,代码行数:9,代码来源:users.php
注:本文中的xml类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论