当前位置: 首页>>代码示例>>PHP>>正文


PHP xml::xml2array方法代码示例

本文整理汇总了PHP中xml::xml2array方法的典型用法代码示例。如果您正苦于以下问题:PHP xml::xml2array方法的具体用法?PHP xml::xml2array怎么用?PHP xml::xml2array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml的用法示例。


在下文中一共展示了xml::xml2array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTree

function getTree($file)
{
    include_once 'classes/Xml_parser.inc';
    include 'conf/_conf.php';
    $_SESSION["_current_file"] = $file;
    $filename = $rules_file . $file;
    if (file_exists($filename)) {
        $file_xml = @file_get_contents($filename, false);
        $_level_key_name = set_key_name($_level_key_name, $file_xml);
        $_SESSION['_level_key_name'] = $_level_key_name;
        if ($file_xml == false) {
            return "2###" . _("Failure to read XML file");
        } else {
            $result = test_conf();
            if ($result !== true) {
                return "3###<div class='errors_ossec'>{$result}</div>";
            }
            $xml_obj = new xml($_level_key_name);
            $xml_obj->load_file($filename);
            return $xml_obj->xml2array();
        }
    } else {
        return "2###" . _("XML file not found");
    }
}
开发者ID:jhbsz,项目名称:ossimTest,代码行数:25,代码来源:utils.php

示例2: basename

    if ($result !== true) {
        $error = true;
        $link_txt = _("Configuration error in file") . " " . basename($ossec_conf) . " " . _("and/or") . " " . $editable_files[0];
        $info_conf = "<span style='font-weight: bold;'>{$link_txt}<a onclick=\"\$('#msg_errors').toggle();\"> [" . _("View errors") . "]</a><br/></span>";
        $info_conf .= "<div id='msg_errors'>{$result}</div>";
        $error_conf = "<div id='parse_errors' class='oss_error'>{$info_conf}</div>";
    } else {
        $file_xml = @file_get_contents($filename, false);
        if ($file_xml === false) {
            $error = true;
        } else {
            $_level_key_name = set_key_name($_level_key_name, $file_xml);
            $_SESSION['_level_key_name'] = $_level_key_name;
            $xml_obj = new xml($_level_key_name);
            $xml_obj->load_file($filename);
            $array_xml = $xml_obj->xml2array();
            $tree_json = array2json($array_xml, $filename);
            $_SESSION['_tree_json'] = $tree_json;
            $_SESSION['_tree'] = $array_xml;
            $file_xml = clean_string($file_xml);
        }
    }
} else {
    $error = true;
}
if ($error == true) {
    $file_xml = '';
    $tree_json = "{title:'<span>" . $filename . "</span>', icon:'../../pixmaps/theme/any.png', addClass:'size12', isFolder:'true', key:'1', children:[{title: '<span>" . _("No Valid XML File") . "</span>', icon:'../../pixmaps/theme/ltError.gif', addClass:'bold_red', key:'load_error'}]}";
    $_SESSION['_tree_json'] = $tree_json;
    $_SESSION['_tree'] = array();
} else {
开发者ID:jhbsz,项目名称:ossimTest,代码行数:31,代码来源:index.php

示例3: xml

if (@copy($path, $path_tmp) == false) {
    echo "2###" . _("Failure to update XML File") . " (1)";
    exit;
}
$result = test_conf();
if ($result !== true) {
    echo "4###" . $result;
    exit;
}
$file_to_text = file_get_contents($path, false);
$_level_key_name = set_key_name($_level_key_name, $file_to_text);
$new_rule['rule'] = $child['tree'];
//Tree local_rules.xml
$xml_obj = new xml($_level_key_name);
$xml_obj->load_file($path);
$tree_lr = $xml_obj->xml2array();
foreach ($tree_lr as $k => $v) {
    if (isset($tree_lr[$k]['group'])) {
        $__level_key = $tree_lr[$k]['group']['@attributes']['__level_key'];
        $child = getChild($tree_lr, $__level_key);
        $keys = array_keys($child['tree']);
        if (is_numeric($keys[count($keys) - 1])) {
            $aux_key = $keys[count($keys) - 1] + 1;
            $new_key = !in_array($aux_key, $keys) ? $aux_key : uniqid(mt_rand("1", mt_getrandmax()));
        } else {
            $new_key = uniqid(mt_rand("1", mt_getrandmax()));
        }
        break;
    }
}
if (empty($new_key)) {
开发者ID:jhbsz,项目名称:ossimTest,代码行数:31,代码来源:copy_rule.php

示例4: foreach

    echo "<td style='padding: 3px 0px 20px 0px;'><form name='cnf_form_rules' id='cnf_form_rules' method='POST'><select id='rules_added' class='multiselect' multiple='multiple' name='rules_added[]'>";
    foreach ($rules_enabled as $k => $v) {
        echo "<option value='{$v}' selected='selected'>{$v}</option>";
    }
    foreach ($no_added_rules as $k => $v) {
        echo "<option value='{$v}' >{$v}</option>";
    }
    echo "</select></form></td>";
    echo "</tr>";
    echo "<tr><td style='padding-bottom:10px;'><input type='button' class='button' id='send' value='" . _('Update') . "' onclick=\"save_config_tab();\"/></td></tr>";
    echo "</table></div>";
} else {
    if ($tab == '#tab2') {
        $xml_obj = new xml("key");
        $xml_obj->load_file($ossec_conf);
        $array_oss_cnf = $xml_obj->xml2array();
        $syscheck = get_nodes($array_oss_cnf, 'syscheck');
        $directories = get_nodes($syscheck, 'directories');
        $wentries = get_nodes($syscheck, 'windows_registry');
        $reg_ignores = get_nodes($syscheck, 'registry_ignore');
        $ignores = get_nodes($syscheck, 'ignore');
        $frequency = get_nodes($syscheck, 'frequency');
        $frequency = $frequency[0][0];
        $scan_day = get_nodes($syscheck, 'scan_day');
        $scan_day = $scan_day[0][0];
        $scan_time = get_nodes($syscheck, 'scan_time');
        $scan_time = $scan_time[0][0];
        $st = !empty($scan_time) ? explode(":", $scan_time) : array();
        $auto_ignore = get_nodes($syscheck, 'auto_ignore');
        $auto_ignore = empty($auto_ignore[0][0]) ? "no" : $auto_ignore[0][0];
        $alert_new_files = get_nodes($syscheck, 'alert_new_files');
开发者ID:jhbsz,项目名称:ossimTest,代码行数:31,代码来源:load_config_tab.php


注:本文中的xml::xml2array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。