mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
Add auto ruleset function
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9982 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
983516dbac
commit
8db1be04bf
7 changed files with 77 additions and 6 deletions
43
classes/xml/XmlGenerator.class.php
Normal file
43
classes/xml/XmlGenerator.class.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
class XmlGenerator{
|
||||
|
||||
function obj2xml($xml){
|
||||
$buff = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
|
||||
|
||||
foreach($xml as $nodeName => $nodeItem){
|
||||
$buff .= $this->_makexml($nodeItem);
|
||||
}
|
||||
return $buff;
|
||||
}
|
||||
|
||||
function _makexml($node){
|
||||
$body = '';
|
||||
foreach($node as $key => $value){
|
||||
switch($key){
|
||||
case 'node_name' : break;
|
||||
case 'attrs' : {
|
||||
$attrs = '';
|
||||
if (isset($value)){
|
||||
foreach($value as $attrName=>$attrValue){
|
||||
$attrs .= sprintf(' %s="%s"', $attrName, htmlspecialchars($attrValue));
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case 'body' : $body = $value; break;
|
||||
default : {
|
||||
if (is_array($value)){
|
||||
foreach($value as $idx => $arrNode){
|
||||
$body .= $this->_makexml($arrNode);
|
||||
}
|
||||
}else if(is_object($value)){
|
||||
$body = $this->_makexml($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sprintf('<%s%s>%s</%s>'."\n", $node->node_name, $attrs, $body, $node->node_name);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue