验证文档 - XmlValidate
函数简介
验证XML文档格式是否正确。
接口名称
XmlValidate
DLL调用
int32_t XmlValidate(int64_t doc, int32_t* err)
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| doc | int64_t | XML文档句柄 |
| err | int32_t* | 错误码输出参数,可为NULL |
示例
int32_t err = 0;
int64_t doc = XmlParseFile("config.xml", &err);
if (XmlValidate(doc, &err)) {
printf("XML文档格式正确\n");
} else {
printf("XML文档格式错误,错误码:%d\n", err);
}
XmlFree(doc);
返回值
| 返回值 | 说明 |
|---|---|
| 0 | 无效 |
| 1 | 有效 |
注意事项
- 验证文档的基本结构是否正确
- 不验证DTD或Schema
- 建议在处理XML前先验证
