xml中出错,想要从xml读取每个节点

本文关键字:xml 读取 节点 出错 | 更新日期: 2023-09-27 18:36:49

下面是myxml字符串,有人可以告诉我这个XML出了什么问题,除此之外,当我尝试加载和读取XML时,它给了我错误无效的字符串,因为我的升级DBTemplate节点包含"和大括号{}如何解决这个问题?

private string DBConfiguration =
                             @"<?xml version=""1.0""?>
                             <ArrayOfDB xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                                      <Database name=""mysql""> 
                                              <UpgradeScriptPath>/Data/upgradescript.xml.config</UpgradeScriptPath>
                                              <DBBinPath>mysql</DBBinPath>
                                              <UpgradeDBTemplate>""{0}"" -h{2} -uroot -p{1} < upgrade_db.txt </UpgradeDBTemplate>
                                      </Database>
                                      <Database name=""mssql""> 
                                              <UpgradeScriptPath> </UpgradeScriptPath>
                                              <DBBinPath>SQLCMD</DBBinPath>
                                              <UpgradeDBTemplate>""{0}"" -S {2} -U sa -p{1} -i upgrade_db.txt</UpgradeDBTemplate>
                                      </Database>
                             </ArrayOfDB >
                             ";

xml中出错,想要从xml读取每个节点

/// <summary>
/// Replaces invalid XML characters in a string with their valid XML equivalent.
/// </summary>
/// <param name="xmlString">The XML string.</param>
/// <returns>Valid Xml</returns>
public static string ReplaceInvalidXml(string xmlString)
{
    return System.Security.SecurityElement.Escape(xmlString);
}