在java中,我想要一个dtd文件中元素的属性列表。
DTD 示例:
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
我需要类似getChilds(note)...
有可能这样做吗?我需要一个 dtd 解析器,但我找不到提供这个的解析器。
谢谢!
You may use a SAX parser, with a DeclHandler.
To set the
DeclHandlerfor an XML reader, use thesetPropertymethod with the property namehttp://xml.org/sax/properties/declaration-handlerand an object implementingDeclHandler. If the reader does not report declaration events, it will throw aSAXNotRecognizedExceptionwhen you attempt to register the handler.
The model argument in method DeclHandler.elementDecl(String name, String model) for name="note" would be (to,from,heading,body).