Dtd validation with libxml2

时间秒杀一切 提交于 2020-01-03 04:16:23

问题


how do i do dtd validation with libxml2? i am reading my xml file using the reader api. i have an external dtd validation file. how do i perform the validation itself? do i have to convert it to xsd?


回答1:


Use xmlValidateDtd api, as described in FAQ, point 11.

This function is used by xmllint application, when --dtdvalid is supplied. See the source file, xmllint.c, parseAndPrintFile function. Search for xmlValidateDtd, it's used only once now.




回答2:


If your are using python as your programming language, try using lxml. This has in-built implementation of libxml2 which is pretty neat in XML DTD validation. And it provides a lot of information which can be helpful in debugging the dtd or xml file.



来源:https://stackoverflow.com/questions/4594049/dtd-validation-with-libxml2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!