本文整理汇总了PHP中xml::import方法的典型用法代码示例。如果您正苦于以下问题:PHP xml::import方法的具体用法?PHP xml::import怎么用?PHP xml::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml
的用法示例。
在下文中一共展示了xml::import方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
static function parse($node, $allow = null, $deny = null)
{
$find = array();
$replace = array();
foreach (self::$find as $n => $rule) {
list($code, $expression) = $rule;
$allowed = !$allow || $allow && in_array($code, $allow);
$denied = $deny && in_array($code, $deny);
if ($allowed && !$denied) {
$find[] = $expression;
$replace[] = self::$replace[$n];
}
}
$xml = new xml();
foreach ($node->children() as $child) {
$xml->append($xml->import($child));
}
foreach ($xml->query('//text()') as $text) {
$parent = $text->parent();
$bbcode = preg_replace($find, $replace, $text->value());
$bbcode = xml::parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><bbcode>{$bbcode}</bbcode>");
foreach ($bbcode->query('/bbcode/* | /bbcode/text()') as $child) {
$parent->insert($xml->import($child), $text);
}
$parent->remove($text);
}
return $xml;
}
示例2: load
function load($filename)
{
$this->xml = xml::load($filename);
$query = array();
foreach (self::$languages as $language) {
$query[] = "/local//{$language}";
}
foreach ($this->xml->query(implode('|', $query)) as $node) {
$doc = new xml();
foreach ($this->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)] = xtree::create($doc);
}
}