xml 的问题
我是 xml 新手...我刚刚开始学习 xml...我有以下疑问.. 以下是我的 xml 代码
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE book [
<!ELEMENT book (page)>
<!ELEMENT page (heading,#PCDATA)>
]>
<note>
<page>
hhh<heading>c</heading><heading>s</heading>
</page>
</note>
当我在浏览器中打开它时,它显示 #PCDATA 有一个错误...当我用 PCDATA 替换它时,它没有显示错误...根据我的 DTD,页面可以包含一个标题元素...我对吗?但是当我在浏览器中打开它时,即使我有两个标题元素,它也没有显示错误..为什么会发生这种情况..CDATA 和 PCDATA 之间有什么区别...
I am novice to xml...I just started studying xml....I have the following doubts..
The following is my xml code
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE book [
<!ELEMENT book (page)>
<!ELEMENT page (heading,#PCDATA)>
]>
<note>
<page>
hhh<heading>c</heading><heading>s</heading>
</page>
</note>
When i opened this in browser ,it shown that there is an error with #PCDATA...when i replaced it with PCDATA it showed no error...According to my DTD, page can contain exactly one heading element...am i right?But when i opened it in browser it showed no error even if i have two heading elements..Why did it happen..Also what is the difference between CDATA and PCDATA....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这个:
Use this:
我的建议是选择一些可靠的验证解析器,例如 AltovaXML (社区版)非常简单使用方法:
让我们看看您的 DTD 有什么问题。首先,您的文档元素(根)未命名为
book
,因此我们从这里得到第一个错误:第二件事是
heading
没有声明:最后允许混合内容将选择与
#PCDATA
(表示已解析的字符数据)首先和heading
元素:最后你的 DTD 是:
My advice is to pick up some solid validating parser, for example AltovaXML (Community Edition) is very straightforward to use:
Let's look what's wrong with your DTD. First of all your document element (root) is not named
book
, so we got first error from here:Second thing is that
heading
is not declared:Finally to allow mixed content put choice with
#PCDATA
(that means parsed character data) at first andheading
element:Finally your DTD is: