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.