c# - XMLDocument 加载(XmlReader)与加载(流)
问题描述
我正在使用带有输入参数的 XMLDocument 加载函数作为流 xml 数据。我看到这样做CA3075的违规行为。对于字符串数据,建议创建 XmlReader 对象并将其传递给 XMLDocument Load 函数,并在参数中将 XMLResolver 值设置为 null。
System.IO.StringReader sreader = new System.IO.StringReader(xml);
XmlReader reader = XmlReader.Create(sreader, new XmlReaderSettings() { XmlResolver = null });
doc.Load(reader);
参考:https ://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca3075#solution-3
我想了解使用 XMLReader 与流作为参数有什么区别?
解决方案
推荐阅读
- github - 如何在 github 上轻松查看带有 ipynb 扩展名的文件
- docker - Docker、微服务和网络
- java - 运行spring批处理作业时无法反序列化执行上下文异常
- javascript - Angular 8对象数组上的多个过滤器
- python - 多项式回归:ValueError:形状(88,1)和(3,1)未对齐:1(dim 1)!= 3(dim 0)
- python - pandas 从 url 读取 .csv,起始行的标题较少
- python-3.x - Keras版本问题有什么神奇的命令吗?
- html - 子 div 超出父 div
- php - 如果选项为否,则需要条件下拉菜单,如果不是,则只显示另一个,否则它必须为空
- node.js - 打字稿和猫鼬:保存到数据库