How to check for valid xml in string input before calling .LoadXml()我更愿意在不捕获
(P)Just catch the exception.The small overhead from catching an exception drowns compared to parsing the xml.(p)(P)如果你想发挥作用(for stylistic reasons,not for performance),落实这一点:(p)字母名称 (P)使用XMLValitingreader将防止例外,如果你提供你自己的有效的可能性。(p) (P)I was unable to get xmlvalidaritinger&;validaritioneventhandler to work.XMLException is still thrown for impully formed xml.我用反射镜检查了这个方法。(p)(P)I indeed need to validate 100s of short xhtml fragments per second.(p)字母名称(P)XMLPARSercontext did not work either.(p)(P)有人跟雷吉克斯在一起吗?(p) (P)如果卡钦对你来说太多,他们可能想在手之前,利用XML计划,验证XML的有效性,以确保XML是OK,但这将证明比卡钦更重要。(p) (P)As already been said,I'd rather catch the exception,but using XMLPARSERcontext,you could try to parse"manually"and interact any anomaly;however,unless you're parsing 100 xml fragments per second,why not catching the exception?(p) |