正则表达式检查 XML 是否格式正确 [英] Regex to check for XML if it is well formed

查看:29
本文介绍了正则表达式检查 XML 是否格式正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有正则表达式用于检查 xml 格式是否正确?

Is there a regex for checking if the xml is well formed ?

谢谢

如果不是正则表达式,那么是否有一个很好的解析方法,我可以在 c# 中使用它不会抛出异常.我尝试使用 xmlReader 但它对我不起作用.

If not regex, then is there a good parsing method that i can use in c# that doesnt throw exception. I tried using xmlReader but it didnt work for me.

推荐答案

超出了正则表达式的能力.换句话说,答案是不可能.

This is well beyond the capabilities of regular expressions. In other words, the answer is that it's not possible.

有很多工具可用于检查格式是否正确,但它们都涉及某种 XML 解析器/验证器.如果您提供有关您的环境的更多信息,也许我们可以为您指明正确的方向.

There are plenty of tools available to check well-formedness, but they all involve some sort of XML parser/validator. If you provide more information about your environment maybe we can point you in the right direction.

这篇关于正则表达式检查 XML 是否格式正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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