使用 xmllint 检查 XML 语法 [英] check XML syntax with xmllint

查看:46
本文介绍了使用 xmllint 检查 XML 语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在处理某些 XML 打印文件时遇到问题,其中源系统忽略将某些字符转换为其等效的 XML 语法(例如 & 未转换为 &).

有没有办法用 xmllint 来捕捉这个?(我不需要使用 XSD 检查通用树结构).

解决方案

xmllint --noout your_test_file.xml

检查此命令的返回码.请参阅文档.遇到基本解析错误时返回1的值.例如:

echo $?

I am having a problem with some XML print files where the source system omits to convert some characters to their XML syntax equivalent (e.g. & is not converted to &).

Is there a way to catch this with xmllint? (I don't need to check the general tree structure using XSD).

解决方案

xmllint --noout your_test_file.xml

Check for return code of this command. See documentation. Value of 1 is returned when basic parsing errors are met. E.g.:

echo $?

这篇关于使用 xmllint 检查 XML 语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆