本文整理汇总了PHP中SimpleXMLExtended类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLExtended类的具体用法?PHP SimpleXMLExtended怎么用?PHP SimpleXMLExtended使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleXMLExtended类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Index
public function Index($rows)
{
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="GBK"?><DOCUMENT/>');
foreach ($rows as $keys => $values) {
foreach ($values as $key => $value) {
$i = -8;
$num_item = $xml->addchild($key);
$num_key = $num_item->addchild('key');
$num_display = $num_item->addchild('display');
$n = 1;
foreach ($value as $k => $val) {
$n++;
if ($n < 3) {
$num_key->addCData($val);
} else {
$i++;
if ($i < 14) {
$num_display->{$k} = NULL;
$num_display->{$k}->addCData($val);
continue;
} elseif ($i == 14) {
$num_moremore = $num_display->addchild('moremore');
$num_moremore->{$k} = NULL;
$num_moremore->{$k}->addCData($val);
}
$num_moremore->{$k} = NULL;
$num_moremore->{$k}->addCData($val);
}
}
}
}
echo $xml->asXml();
}
示例2: items_customfields_header
function items_customfields_header()
{
if (!file_exists(GSDATAOTHERPATH . 'plugincustomfields.xml')) {
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
$xml->asXML(GSDATAOTHERPATH . 'plugincustomfields.xml');
return true;
}
?>
<style type="text/css">
form #metadata_window table.formtable td .cke_editor td:first-child { padding: 0; }
form #metadata_window table.formtable .cke_editor td.cke_top { border-bottom: 1px solid #AAAAAA; }
form #metadata_window table.formtable .cke_editor td.cke_contents { border: 1px solid #AAAAAA; }
#customfieldsForm .hidden { display:none; }
.shorts {
width:250px !important;
}
.checkp {
margin-top:17px;
}
.user_sub_tr {
border:0px;border-bottom:0px !important; border-bottom-width:0px !important;border-top:0px;border-top-width:0px !important;
}
.user_sub_tr td{
border:0px;border-bottom:0px !important;border-bottom-width:0px !important;padding-top:6px !important; border-top: 0px !important;
}
.resize_img {
max-height:150px;
}
</style>
<?php
}
示例3: _xmlbody
/**
* build the xml structure where the content can be inserted
*
* @return void
*/
private function _xmlbody()
{
$dom = new DOMDocument('1.0', 'UTF-8');
$root = $dom->createElement("tns:phpsysinfo");
$root->setAttribute('xmlns:tns', 'http://phpsysinfo.sourceforge.net/');
$root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$root->setAttribute('xsi:schemaLocation', 'http://phpsysinfo.sourceforge.net/phpsysinfo3.xsd');
$dom->appendChild($root);
$this->_xml = new SimpleXMLExtended(simplexml_import_dom($dom), $this->_sysinfo->getEncoding());
$generation = $this->_xml->addChild('Generation');
$generation->addAttribute('version', CommonFunctions::PSI_VERSION);
$generation->addAttribute('timestamp', time());
$options = $this->_xml->addChild('Options');
$options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? PSI_TEMP_FORMAT : 'c');
$options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? PSI_BYTE_FORMAT : 'auto_binary');
$options->addAttribute('refresh', defined('PSI_REFRESH') ? PSI_REFRESH : 0);
$options->addAttribute('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE') ? PSI_SHOW_PICKLIST_TEMPLATE ? 'true' : 'false' : 'false');
$options->addAttribute('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG') ? PSI_SHOW_PICKLIST_LANG ? 'true' : 'false' : 'false');
$plug = $this->_xml->addChild('UsedPlugins');
if ($this->_complete_request && count($this->_plugins) > 0) {
foreach ($this->_plugins as $plugin) {
$plug->addChild('Plugin')->addAttribute('name', $plugin);
}
} elseif ($this->_plugin_request && count($this->_plugins) > 0) {
$plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
}
}
示例4: node
/**
* 增加节点值
* @param array $data
* @param SimpleXMLElement $xml
*
* @return void
*/
public static function node($data, SimpleXMLExtended &$xml)
{
foreach ($data as $k => $v) {
if (is_array($v)) {
is_numeric($k) && ($k = substr($xml->getName(), 0, -1));
$subroot = $xml->addChild($k);
self::node($v, $subroot);
} else {
if (is_numeric($v)) {
$xml->addChild($k, $v);
} else {
$xml->addChild($k)->addCData($v);
}
}
}
}
示例5: export_category
public function export_category()
{
$id = $this->session->userdata('admin_id');
$cates = $this->catenews_model->list_all_byuser($id);
$xml = new SimpleXMLExtended("<root></root>");
foreach ($cates as $cate) {
$xml_post = $xml->addChild('category');
$xml_post->addChild('cat_id', $cate->id);
$content = $xml_post->addChild('cat_name');
$content->addCData($cate->catenewsname);
}
$dom = new DOMDocument("1.0");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
$xml->asXML('export/' . $id . '/category.xml');
}
示例6: bm_cache_to_xml
function bm_cache_to_xml($books)
{
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
foreach ($books as $book) {
$item = $xml->addChild('item');
$elem = $item->addChild('slug');
$elem->addCData($book['slug']);
$elem = $item->addChild('title');
$elem->addCData($book['title']);
$elem = $item->addChild('date');
$elem->addCData($book['date']);
$elem = $item->addChild('tags');
$elem->addCData($book['tags']);
$elem = $item->addChild('private');
$elem->addCData($book['private']);
}
return @XMLsave($xml, BMBOOKCACHE);
}
示例7: _xmlbody
/**
* build the xml structure where the content can be inserted
*
* @return void
*/
private function _xmlbody()
{
$dom = new DOMDocument('1.0', 'UTF-8');
$root = $dom->createElement("tns:phpsysinfo");
$root->setAttribute('xmlns:tns', 'http://phpsysinfo.sourceforge.net/');
$root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$root->setAttribute('xsi:schemaLocation', 'http://phpsysinfo.sourceforge.net/ phpsysinfo3.xsd');
$dom->appendChild($root);
$this->_xml = new SimpleXMLExtended(simplexml_import_dom($dom), $this->_sysinfo->getEncoding());
$generation = $this->_xml->addChild('Generation');
$generation->addAttribute('version', PSI_VERSION_STRING);
$generation->addAttribute('timestamp', time());
$options = $this->_xml->addChild('Options');
$options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? strtolower(PSI_TEMP_FORMAT) : 'c');
$options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? strtolower(PSI_BYTE_FORMAT) : 'auto_binary');
if (defined('PSI_REFRESH')) {
if (PSI_REFRESH === false) {
$options->addAttribute('refresh', 0);
} elseif (PSI_REFRESH === true) {
$options->addAttribute('refresh', 1);
} else {
$options->addAttribute('refresh', PSI_REFRESH);
}
} else {
$options->addAttribute('refresh', 60000);
}
if (defined('PSI_FS_USAGE_THRESHOLD')) {
if (PSI_FS_USAGE_THRESHOLD === true) {
$options->addAttribute('threshold', 1);
} elseif (PSI_FS_USAGE_THRESHOLD !== false && PSI_FS_USAGE_THRESHOLD >= 1 && PSI_FS_USAGE_THRESHOLD <= 99) {
$options->addAttribute('threshold', PSI_FS_USAGE_THRESHOLD);
}
} else {
$options->addAttribute('threshold', 90);
}
$options->addAttribute('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE') ? PSI_SHOW_PICKLIST_TEMPLATE ? 'true' : 'false' : 'false');
$options->addAttribute('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG') ? PSI_SHOW_PICKLIST_LANG ? 'true' : 'false' : 'false');
$options->addAttribute('showCPUListExpanded', defined('PSI_SHOW_CPULIST_EXPANDED') ? PSI_SHOW_CPULIST_EXPANDED ? 'true' : 'false' : 'true');
$options->addAttribute('showCPUInfoExpanded', defined('PSI_SHOW_CPUINFO_EXPANDED') ? PSI_SHOW_CPUINFO_EXPANDED ? 'true' : 'false' : 'false');
if (count($this->_plugins) > 0) {
if ($this->_plugin_request) {
$plug = $this->_xml->addChild('UsedPlugins');
$plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
} elseif ($this->_complete_request) {
$plug = $this->_xml->addChild('UsedPlugins');
foreach ($this->_plugins as $plugin) {
$plug->addChild('Plugin')->addAttribute('name', $plugin);
}
} else {
$plug = $this->_xml->addChild('UnusedPlugins');
foreach ($this->_plugins as $plugin) {
$plug->addChild('Plugin')->addAttribute('name', $plugin);
}
}
}
}
示例8: saveTemplate
function saveTemplate($data)
{
My_Logger::log("in Ajax_TemplateEditorProcessor saveTemplate()");
$expected = array('filename', 'type', 'time', 'concepts', 'instructions', 'problem');
$filename = $this->get($data['filename']);
if (empty($filename)) {
throw new Exception('Missing Filename');
}
My_Logger::log("filename is " . $filename);
foreach ($expected as $field) {
$toCheck = $this->get($data[$field]);
if (empty($toCheck)) {
//if (empty($this->get($data[$field]))){
throw new Exception('Missing field: ' . $field);
}
}
//build xml
$xml = new SimpleXMLExtended('<question/>');
$xml->addAttribute('type', $this->get($data['type']));
$xml->addChild('estimated_time', $this->get($data['time']));
$concepts = $xml->addChild('concepts');
$concepts->addChild('concept', $this->get($data['concepts']));
$xml->addChild('difficulty', $this->get($data['difficulty']));
$xml->addChild('instructions', $this->get($data['instructions']));
//$xml->problem = null;
//$xml->problem->addCData($this->get($data['problem']));
$xml->addCData('problem', $this->get($data['problem']));
$sc = $xml->addChild('substitutions');
$subs = $this->get($data['s']);
if ($subs) {
foreach ($subs as $sd) {
if (empty($sd['name']) || empty($sd['value'])) {
continue;
}
$s = $sc->addCData('substitution', $sd['value']);
$s->addAttribute('val', $sd['name']);
}
}
$config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", APPLICATION_ENV);
$path = $config->xml->import_path;
$full_filename = $path . DIRECTORY_SEPARATOR . $filename;
My_Logger::log("Saving to {$full_filename}");
$xml->saveXML($full_filename);
chmod($full_filename, 0666);
return array('result' => 'success', 'msg' => "File '{$filename}' saved correctly");
}
示例9: toXml
/**
* Function for converting to an XML document.
* Pass in a multi dimensional array or object 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 = 'root', $xml = null, $encoding = 'utf-8', $cdata = false)
{
// 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 = new SimpleXMLExtended("<?xml version='1.0' encoding='" . $encoding . "'?><{$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...
//return;
$key = "row";
}
// if there is another array or object found recrusively call this function
if (is_array($value) || is_object($value)) {
$node = $xml->addChild($key);
// recrusive call.
self::toXml($value, $rootNodeName, $node, $encoding, $cdata);
} else {
// add single node.
$value = is_bool($value) ? $value ? 'true' : 'false' : $value;
$value = htmlspecialchars($value);
if ($cdata === true) {
$node = $xml->addChild($key);
$node->addCData($value);
} else {
$xml->addChild($key, $value);
}
}
}
// pass back as string. or simple xml object if you want!
return $xml->asXML();
}
示例10: bm_save_book
function bm_save_book()
{
# create a backup if necessary
if (isset($_POST['current-slug'])) {
$file = $_POST['current-slug'] . '.xml';
@rename(BMBOOKPATH . $file, BMBACKUPPATH . $file);
}
# empty titles are not allowed
if (empty($_POST['book-title'])) {
$_POST['book-title'] = '[No Title]';
}
# set initial slug and filename
if (!empty($_POST['book-slug'])) {
$slug = bm_create_slug($_POST['book-slug']);
} else {
$slug = bm_create_slug($_POST['book-title']);
}
$file = BMBOOKPATH . "{$slug}.xml";
# do not overwrite other books
if (file_exists($file)) {
$count = 1;
$file = BMBOOKPATH . "{$slug}-{$count}.xml";
while (file_exists($file)) {
$file = BMBOOKPATH . "{$slug}-" . ++$count . '.xml';
}
$slug = basename($file, '.xml');
}
# create undo target if there's a backup available
if (isset($_POST['current-slug'])) {
$backup = $slug . ':' . $_POST['current-slug'];
}
# collect $_POST data
$title = safe_slash_html($_POST['book-title']);
$timestamp = strtotime($_POST['book-date'] . ' ' . $_POST['book-time']);
$date = $timestamp ? date('r', $timestamp) : date('r');
$tags = str_replace(array(' ', ',,'), array('', ','), safe_slash_html($_POST['book-tags']));
$private = isset($_POST['book-private']) ? 'Y' : '';
$content = safe_slash_html($_POST['book-content']);
# create xml object
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
$obj = $xml->addChild('title');
$obj->addCData($title);
$obj = $xml->addChild('date');
$obj->addCData($date);
$obj = $xml->addChild('tags');
$obj->addCData($tags);
$obj = $xml->addChild('private');
$obj->addCData($private);
$obj = $xml->addChild('content');
$obj->addCData($content);
# write data to file
if (@XMLsave($xml, $file) && bm_update_cache()) {
bm_display_message(i18n_r('books_manager/SUCCESS_SAVE'), false, @$backup);
} else {
bm_display_message(i18n_r('books_manager/SUCCESS_SAVE'), false, @$backup);
}
}
示例11: nm_cache_to_xml
function nm_cache_to_xml($posts)
{
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
foreach ($posts as $post) {
$item = $xml->addChild('item');
$elem = $item->addChild('slug');
$elem->addCData($post['slug']);
$elem = $item->addChild('title');
$elem->addCData($post['title']);
$elem = $item->addChild('date');
$elem->addCData($post['date']);
$elem = $item->addChild('tags');
$elem->addCData($post['tags']);
$elem = $item->addChild('private');
$elem->addCData($post['private']);
$elem = $item->addChild('image');
$elem->addCData($post['image']);
if (!empty($post['author'])) {
$elem = $item->addChild('author');
$elem->addCData($post['author']);
}
}
return @XMLsave($xml, NMPOSTCACHE);
}
示例12: printXML
/**
* @author Panagiotis Vagenas <pan.vagenas@gmail.com>
* @since 150213
*/
public function printXML()
{
if (headers_sent()) {
return;
}
if (!$this->simpleXML instanceof SimpleXMLExtended) {
$fileLocation = $this->getFileLocation();
if (!$this->existsAndReadable($fileLocation)) {
die('EW:X:P');
}
$this->simpleXML = simplexml_load_file($fileLocation);
}
header("Content-Type:text/xml");
echo $this->simpleXML->asXML();
exit(0);
}
示例13: nm_save_post
function nm_save_post()
{
# create a backup if necessary
if (isset($_POST['current-slug'])) {
$file = $_POST['current-slug'] . '.xml';
if (dirname(realpath(NMPOSTPATH . $file)) != realpath(NMPOSTPATH)) {
die('');
}
// path traversal
@nm_rename_file(NMPOSTPATH . $file, NMBACKUPPATH . $file);
}
# empty titles are not allowed
if (empty($_POST['post-title']) || trim($_POST['post-title']) == '') {
$_POST['post-title'] = '[No Title]';
}
# set initial slug and filename
if (!empty($_POST['post-slug'])) {
$slug = nm_create_slug($_POST['post-slug']);
} else {
$slug = nm_create_slug($_POST['post-title']);
if ($slug == '') {
$slug = 'post';
}
}
$file = NMPOSTPATH . $slug . '.xml';
# do not overwrite other posts
if (file_exists($file)) {
$count = 1;
$file = NMPOSTPATH . $slug . '-' . $count . '.xml';
while (file_exists($file)) {
$file = NMPOSTPATH . $slug . '-' . ++$count . '.xml';
}
$slug = basename($file, '.xml');
}
# create undo target if there's a backup available
if (isset($_POST['current-slug'])) {
$backup = $slug . ':' . $_POST['current-slug'];
}
# collect $_POST data
$title = safe_slash_html($_POST['post-title']);
$timestamp = strtotime($_POST['post-date'] . ' ' . $_POST['post-time']);
$date = $timestamp ? date('r', $timestamp) : date('r');
$tags = nm_lowercase_tags(trim(preg_replace(array('/\\s+/', '/\\s*,\\s*/', '/,+/'), array(' ', ',', ','), safe_slash_html(trim($_POST['post-tags']))), ','));
$private = isset($_POST['post-private']) ? 'Y' : '';
$image = safe_slash_html($_POST['post-image']);
$content = safe_slash_html($_POST['post-content']);
if (defined('NMSAVEAUTHOR') && NMSAVEAUTHOR) {
if (isset($_POST['author'])) {
$author = safe_slash_html($_POST['author']);
} else {
global $USR;
$author = $USR ? $USR : '';
}
}
# create xml object
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
$obj = $xml->addChild('title');
$obj->addCData($title);
$obj = $xml->addChild('date');
$obj->addCData($date);
$obj = $xml->addChild('tags');
$obj->addCData($tags);
$obj = $xml->addChild('private');
$obj->addCData($private);
$obj = $xml->addChild('image');
$obj->addCData($image);
$obj = $xml->addChild('content');
$obj->addCData($content);
if (isset($author)) {
$obj = $xml->addChild('author');
$obj->addCData($author);
}
# write data to file
if (@XMLsave($xml, $file) && nm_update_cache()) {
nm_generate_sitemap();
nm_display_message(i18n_r('news_manager/SUCCESS_SAVE'), false, @$backup);
} else {
nm_display_message(i18n_r('news_manager/ERROR_SAVE'), true);
}
}
示例14: i18n_r
$sel = '';
$count++;
}
$langs .= '</select><br />';
} else {
$langs = '<b>' . i18n_r('LANGUAGE') . '</b>: <code style="color:red;">' . i18n_r('NONE') . '</code> ';
}
# salt value generation
$api_file = GSDATAOTHERPATH . GSAUTHFILE;
if (!file_exists($api_file)) {
if (getDef('GSUSECUSTOMSALT')) {
$saltval = sha1(GSUSECUSTOMSALT);
} else {
$saltval = generate_salt();
}
$xml = new SimpleXMLExtended('<item></item>');
$note = $xml->addChild('apikey');
$note->addCData($saltval);
if (!XMLsave($xml, $api_file)) {
$kill = i18n_r('CHMOD_ERROR');
}
}
# get salt value
$data = getXML($api_file);
$APIKEY = $data->apikey;
if (empty($APIKEY)) {
$kill = i18n_r('CHMOD_ERROR');
}
$pagetitle = $site_full_name . ' · ' . i18n_r('INSTALLATION');
get_template('header');
?>
示例15: delete_in_category
function delete_in_category($file)
{
$data = getXML($file);
$section = $data->parent;
$id = $data->url;
$files = CATEGORIESPATH . '' . $section . '.xml';
if (file_exists($files)) {
$p = 0;
$data = getXML($files);
$array = array();
foreach ($data->children() as $child) {
if (sprintf("%s", $child) != $id) {
$array[$p] = sprintf("%s", $child);
$p++;
}
}
//$array=array_reverse($array);
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
$xml->addChild('pubDate', date('r'));
for ($i = 1; $i < $p; $i++) {
$note = $xml->addChild('f' . $i);
$note->addCData($array[$i]);
}
XMLsave($xml, $files);
}
}