XML - DTD 问题
XML - DTD Issue
我正在尝试将 DTD 应用于 XML 文档(我是 XML 的新手)。我在代码中收到以下错误。除此之外还有更好的方法来应用 DTD 吗?
<!DOCTYPE chat [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<chat>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
</chat>
错误
Element type "chat" must be declared.
Parth - 试试这个
<!DOCTYPE chat [
<!ELEMENT chat (note*)>
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
我正在尝试将 DTD 应用于 XML 文档(我是 XML 的新手)。我在代码中收到以下错误。除此之外还有更好的方法来应用 DTD 吗?
<!DOCTYPE chat [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<chat>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
</chat>
错误
Element type "chat" must be declared.
Parth - 试试这个
<!DOCTYPE chat [
<!ELEMENT chat (note*)>
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>