我有一些xml所在的字符串。刪除字符串中的反斜槓C#
的字符串是:
string xmlRead = "<ns0:RequestedAmount xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\"> <ns0:RequestedAmount></ns0:RequestedAmount> </ns0:RequestedAmount>" +
"<ns0:Response xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\"> <ns0:Response/> </ns0:Response>" +
"<ns0:isValid xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\"> <ns0:isValid/> </ns0:isValid>";
我已經試過這樣:
string s=xmlRead.Replace(@"\","");
string s=xmlRead.Replace("\"","");
string s=xmlRead.Replace(@"\",string.Empty);
沒有什麼工作好心幫助我什麼,我做錯了。
該字符串中沒有反斜槓,我可以看到。我能看到的都是逃脫的字符,例如''''只在字符串中加入''''。 –
但是當我傳遞這個字符串Xml.Create方法時,它給出了路徑中的非法字符的異常,並且當我傳遞沒有這個字符串時它工作正常。 –
Xml.Create是什麼意思?在'XmlDocument'和'XDocument'類中都沒有'Create'方法,我不知道任何剛纔調用'Xml'的.NET Framework類。 –