c#parsingxmlwithandapostrophethrowsexception问题。当项目名称不包含所有内容时,一切正常。我试过用不同的转义字符替换撇号,但运气不佳strings="/itemDB/item[@name='"+itemName+"']";//我试过但没有用的东西//s.Replace("'","''");//。代替(”'”,”'”);XmlNodeparent=root.SelectSingleNode(s);我不断收到XPathException。执行此操作的正确方法是什么。谢谢你可以这样做:XmlDocumentroot=newXmlDocument();root.LoadXml(@"");XmlNodenode=root.SelectSingleNode(@"itemDB/item[@name=""abc'def""]");请注意逐字字符串文字“@”和双引号。如果不替换任何内容,您的代码将如下所示:varitemName=@"abc'def";字符串s=@"/itemDB/item[@name="""+itemName+@"""]";对于Apostrophe,use'replaceit'以上是C#学习教程:c#parsingxmlwithandapostrophethrowingexception全部内容分享,如果对大家有用需要了解更多C#学习教程,希望大家多多付出注意——本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
