+ -
当前位置:首页 → 问答吧 → XML标签语法错误

XML标签语法错误

时间:2011-06-08

来源:互联网



我是新手用2.0版,正在运行论坛中的一步一步循序渐进学习TP,

Lib/Action/IndexAction.class.php

<?php
class IndexAction extends Action{
    public function index(){
        $array = array();
        $array['name']    =    "thinkphp";
        $array['email']   =    "[email protected]";
        $array['phone']   =    "12335678";
        $value  =   "hello,ThinkPHP";
        $this->assign('array',$array);
        $this->assign('name',$value);
        $this->display();
    }
}
?>

Tpl/default/index/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>{$name}</title>
</head>
<body>
<iterate name="array" id="vo">
{$vo}<br />
</iterate>
</body>
</html>


错误信息如下,请问如何解决?谢谢!



错误位置: FILE: C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\TagLib.class.php LINE: 274
[ 错误信息 ]
XML标签语法错误 : name='array' id='vo'
[ TRACE ]
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\TagLib.class.php (274) throw_exception(XML标签语法错误 : name='array' id='vo')
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\TagLib\TagLibCx.class.php (89) TagLibCx->parseXmlAttr(name='array' id='vo', iterate)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\TagLib\TagLibCx.class.php (120) TagLibCx->_volist(name='array' id='vo', {$vo}
)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\ThinkTemplate.class.php (421) TagLibCx->_iterate(name='array' id='vo', {$vo}
)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\ThinkTemplate.class.php(384) : regexp code (3) ThinkTemplate->parseXmlTag(cx, iterate, name=\'array\' id=\'vo\',
{$vo}

)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\ThinkTemplate.class.php (384) preg_replace(/(.+?)<\/iterate(\s*?)>/eis, $this->parseXmlTag('cx','iterate','\1','\2'),






{$vo}





)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\ThinkTemplate.class.php (260) ThinkTemplate->parseTagLib(cx,






{$vo}





, 1)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\ThinkTemplate.class.php (160) ThinkTemplate->parse(






{$vo}





)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\ThinkTemplate.class.php (135) ThinkTemplate->compiler(






{$vo}





)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Template\ThinkTemplate.class.php (96) ThinkTemplate->loadTemplate(./Myapp/Tpl/default/Index/index.html)
[11-06-08 15:47:06] C:\PHPMysql\www\6\ThinkPHP\Lib\Think\Util\Template\TemplateThink.class.php (45) ThinkTemplate->load(./Myapp/Tpl/default/Index/index.html, Array, utf-8)
[11-06-08 15:47:06] C:\PHPMysql\www\6\Myapp\Runtime\~runtime.php (2) TemplateThink->fetch(./Myapp/Tpl/default/Index/index.html, Array, utf-8)
[11-06-08 15:47:06] C:\PHPMysql\www\6\Myapp\Runtime\~runtime.php (2) View->fetch(, , text/html, 1)
[11-06-08 15:47:06] C:\PHPMysql\www\6\Myapp\Runtime\~runtime.php (2) View->display(, , text/html)
[11-06-08 15:47:06] C:\PHPMysql\www\6\Myapp\Lib\Action\IndexAction.class.php (11) IndexAction->display()
[11-06-08 15:47:06] C:\PHPMysql\www\6\Myapp\Runtime\~runtime.php (2) IndexAction->index()
[11-06-08 15:47:06] C:\PHPMysql\www\6\Myapp\Runtime\~runtime.php (2) call_user_func(Array)
[11-06-08 15:47:06] C:\PHPMysql\www\6\Myapp\Runtime\~runtime.php (2) App::exec()
[11-06-08 15:47:06] C:\PHPMysql\www\6\index.php (13) App::run()

作者: Hadron74   发布时间: 2011-06-08

2.1下没有问题的;
你可以试着将模板中改为{$vo.name}试下

另外不要用这类关键字符来定义变量 ,$this->assign('array',$array);
好的习惯可以避免很多麻烦。

作者: top   发布时间: 2011-06-08