1

下面是 myxml 字符串,有人能告诉我这个 xml 有什么问题吗,除此之外,当我尝试加载和读取 xml 时,它给了我错误 Invalid string since my UpgradeDBTemplate 节点包含“”和花括号 {} 如何解决这个问题?

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 >
                             ";
4

1 回答 1

0
/// <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);
}
于 2013-10-24T18:41:09.413 回答