- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我从下面的代码块中得到以下异常。
解析 EntityName 时出错。 Line1,位置 844。
我试图将从表中检索到的数据集解析为数据集。
public DataSet BindMasterData(string xml)
{
DataSet ds = null;
try
{
ds = new DataSet();
TextReader txtReader = new StringReader(xml);
XmlReader reader = new XmlTextReader(txtReader);
ds.ReadXml(reader);
}
catch (Exception ex)
{
return new DataSet();
}
return ds;
}
我已经找到异常的原因了,但是我无法解决。在这种特殊情况下,字符串(从数据库中检索)包含一个特殊字符 (&)。这会导致异常。我该如何解决。在这方面的任何帮助都会很棒。
最佳答案
只需替换它们:
在 XML 元素中无效:
" "
' '
< <
> >
& &
public static string UnescapeXMLValue(string xmlString)
{
if (xmlString == null)
throw new ArgumentNullException("xmlString")
return xmlString.Replace("'", "'").Replace(""", "\"").Replace(">", ">").Replace("<", "<").Replace("&", "&");
}
public static string EscapeXMLValue(string xmlString)
{
if (xmlString == null)
throw new ArgumentNullException("xmlString")
return xmlString.Replace( "&","&").Replace("'","'").Replace( "\"", """).Replace(">",">").Replace( "<","<");
}
关于c# - 解析 EntityName 时出错。 Line1,位置 844,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23541910/
SENARIO 我正在开发一个项目,将 Swift 3 合并到 Objective-C 项目中。该项目正在使用 CoreData,在我的 Objective-C AppDelegate 中,我声明了“
我使用简单的值,但我从未使用过值。(实体名称)。所以我对此感到困惑。我认为值用于获取当前值,但我在这里不明白。 public Tax Tax { get
我们在野外遇到过这种崩溃,当然我们不能在本地进行 repo 。它似乎只发生在 ios 7 上。它是一个 NSInternalInconsistencyException 的事实告诉我们这是一个内部 N
我是 coreData 编程的新手,我按照教程一步一步进行,当我收到此错误并陷入困境时,不知道这意味着什么 entityName.state must have a defined type
我正在尝试将 xml 文档加载到 C# 中的对象 XPathDocument 中。我的 xml 文档包括这一行:trés dégagée + rade当解析器到达那里时,它给了我这个错误:“解析 En
当使用“instruments”跟踪未引用的分配时,我看到了数千个 CDSnapshot[entityName]_ 实例。 这是什么?我认为它与 CoreData 相关? 最佳答案 是的,这与核心数据
我已经开始学习 Hibernate 并且有一个基本问题。 org.hibernate.Session 中的save(String entityName, Object object) 和save(Ob
以下查询有效: @Query("select o from Employee o where o.tenant.id = ?#{context.tenantId}") @Query("select o
在 Microsoft 的 Dynamics CRM 2011 实践实验室之后,我尝试将自定义 View 添加到响应特定属性的“onchange”的表单。这是我添加自定义 View 的函数: func
我发现我的代码中存在"&",这就是显示错误的原因 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dsExport.Tables[0].R
当我设计QueryExpression 时,我总是使用以下硬编码语法。 QueryExpression expression = new QueryExpression { EntityName
我知道这可能看起来重复,但我尝试了几个答案,但所有这些都不起作用。 我正在尝试使用核心数据来存储已完成的级别,但我在保存数据时遇到了一些麻烦。当一个级别完成时,将调用以下行。 let appD
Xcode 8 在您的 NSManagedObject 子类上提供了一个自动生成的 extension,看起来像这样: // Animal+CoreDataProperties.swift impo
我正在为我的 winforms 应用程序使用自定义控制代码来创建自定义彩色进度条。我可以构建它,它工作正常,但每次我尝试使用设计器时,它都会崩溃。 “解析 EntityName 时出错” 如果我从工具
我在 Swift 2.1 和 Xcode 7.2 中使用核心数据此代码给我一个无法找到实体名称的错误。这因为 [Company] 不起作用。我有一个具有此名称的实体。 let fetchReq
我从下面的代码块中得到以下异常。 解析 EntityName 时出错。 Line1,位置 844。 我试图将从表中检索到的数据集解析为数据集。 public DataSet BindMasterDat
我有一个函数,我将一个字符串作为参数传递给名为 filterXML 的参数,其中一个属性中包含“&”。 我知道 XML 不会识别它,它会给我一个错误。这是我的代码: public XmlDocume
我正在尝试对我的实体之一的属性使用延迟加载 属性映射是这样的: 但是,当我尝试保存此实体的实例(使用 Linq)时,它会抛出 DatabaseQueryException 并带有以下内部异常: NH
我首先使用实体框架 6 代码。我有三个这样的实体: public class Doctor { public string DoctorID { get; set; } publi
我升级了一个从 ef4 开始的旧项目,但现在我将它迁移到了 ef5。 这是旧代码: protected void SaveEntity(T entity) { using (DocsM
我是一名优秀的程序员,十分优秀!