本文整理汇总了PHP中WebVista_Model_ORM::recurseXml方法的典型用法代码示例。如果您正苦于以下问题:PHP WebVista_Model_ORM::recurseXml方法的具体用法?PHP WebVista_Model_ORM::recurseXml怎么用?PHP WebVista_Model_ORM::recurseXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebVista_Model_ORM
的用法示例。
在下文中一共展示了WebVista_Model_ORM::recurseXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recurseXml
public static function recurseXml($data, $rootNodeName = 'data', $xml = null)
{
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) {
if (is_object($data) && method_exists($data, "get_" . $key)) {
//$value = call_user_method("get",$data,$key);
$value = $data->get($key);
}
// no numeric keys in our xml please!
if (is_numeric($key)) {
// make string key...
//$key = "unknownNode_". (string) $key;
$key = "array";
}
// replace anything not alpha numeric
$key = preg_replace('/[^a-z_0-9]/i', '', $key);
// if there is another array found recrusively call this function
if (strpos($key, '_') === 0) {
} else {
if (is_array($value) || is_object($value)) {
$node = $xml->addChild($key);
// recrusive call.
WebVista_Model_ORM::recurseXml($value, $rootNodeName, $node);
} else {
// add single node.
if (is_resource($value)) {
$value = "resource";
}
$value = htmlentities(iconv("UTF-8", "ASCII//TRANSLIT", $value));
$xml->addChild($key, $value);
}
}
}
// pass back as string. or simple xml object if you want!
$xmlstr = $xml->asXML();
return preg_replace('/<\\?.*\\?>/', '', $xmlstr);
}
示例2: toXml
function toXml()
{
return WebVista_Model_ORM::recurseXml($this->_data, $this->systemName);
}