我试图用HXT解析以下XML文档
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Key</key>
<string>Value</string>
</dict>
</plist>我不想在这里进行任何验证,因为它需要网络访问。不幸的是,HXT仍然希望安装hxt-curl / hxt-http包来解析这个简单的文档:
Prelude> :m +Text.XML.HXT.Core
Prelude Text.XML.HXT.Core> runX $ readDocument [withValidate no] "example.xml"
fatal error: HTTP handler not configured,
please install package hxt-curl and use 'withCurl' config option
or install package hxt-http and use 'withHTTP' config option我不想将hxt-curl/hxt-http包添加到依赖项列表中,因为我并不真正需要它们。我不能改变我解析的文档。转移到另一个xml解析库也是不可取的。
有没有一种不用添加不必要的包就可以用HXT解析示例文档的方法?
发布于 2014-04-04 09:21:46
您还必须声明withSubstDTDEntities no,即。
runX $ readDocument [withValidate no, withSubstDTDEntities no] "example.xml"说明:这个配置的缺省值是“是”,这就是为什么hxt尝试下载dtd文件的原因。来自the documentation
切换此选项和关闭验证可以导致更快的解析,在这种情况下,不再需要读取DTD文档。
https://stackoverflow.com/questions/22856806
复制相似问题