1.以文本的方式读取出xml内容

2.如果xml加载文本失败,替换掉乱码的内容

private static void loadxml(XmlDocument doc, string str)
{
try
{
doc.LoadXml(str);
}
catch (System.Xml.XmlException ex)
{
long count = 1;
int position = 0;
while (count < ex.LineNumber && (position = str.IndexOf('\n', position)) != -1)
{
count++;
position++;
}
string Newstr=str.Replace(str.Substring(position + ex.LinePosition - 1, 1), "");

loadxml(doc, Newstr);
}
}

 

相关文章:

  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-26
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2021-12-27
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案