How to check for valid xml in string input before calling .LoadXml()

后端 未结 5 508
一个人的身影
一个人的身影 2020-11-30 05:48

I would much prefer to do this without catching an exception in LoadXml() and using this results as part of my logic. Any ideas for a solution that doesn\'t in

5条回答
  •  一生所求
    2020-11-30 06:14

    AS already been said, I'd rather catch the exception, but using XmlParserContext, you could try to parse "manually" and intercept any anomaly; however, unless you're parsing 100 xml fragments per second, why not catching the exception?

提交回复
热议问题