XML 转为字符串的通过用方式

通用的xml 转为字符串 
public static string GetXMLAsString(string xmlPath)
{
XmlDocument doc = new XmlDocument();
doc.Load(xmlPath);
// doc.Load("C:\\Users\\Administrator\\Desktop\\ConsoleApp\\1.xml");
StringWriter sw = new StringWriter();
XmlTextWriter tx = new XmlTextWriter(sw);
doc.WriteTo(tx);

string str = sw.ToString();//
return str;
}

  

posted @ 2022-09-17 14:47  LowKeyC  阅读(866)  评论(0编辑  收藏  举报
有志者事竟成破釜沉舟百二秦关终属楚苦心人,天不负,卧薪尝胆,三千越甲可吞吴