English 中文(简体)
XmlDocumentshanging “在划分实体名称时发生错误”
原标题:XmlDocument throwing "An error occurred while parsing EntityName"

我有这样的职能,即我通过一个称为过滤器XML的灯塔,其中含有和安放;在其中一种特性中。

我知道,XML不会承认它,它将向我扔.。 我的守则是:

 public XmlDocument TestXMLDoc(string filterXml)
{
    XmlDocument doc = new XmlDocument();
    XmlNode root = doc.CreateElement("ResponseItems");

    // put that root into our document (which is an empty placeholder now)
    doc.AppendChild(root);

    try
    {
        XmlDocument docFilter = new XmlDocument();
        docFilter.PreserveWhitespace = true;

        if (string.IsNullOrEmpty(filterXml) == false)
            docFilter.LoadXml(filterXml); //ERROR THROWN HERE!!!

我的法典应作些什么改动,以ed或 par子过滤器? 我的过滤Xml认为:

<Testing>
<Test>CITY & COUNTY</Test>
</Testing>

我正在从安放、到安放地改变我的巨大价值。 我的守则就是:

string editXml = filterXml;
    if (editXml.Contains("&"))
    {
        editXml.Replace( & ,  &amp; );
    }

But its giving me an err on inside the if statement : Too many literals.

最佳回答

上文所示档案没有经过充分了解的XML,因为安放器无法逃脱。

你可以尝试:

<Testing>
  <Test>CITY &amp; COUNTY</Test>
</Testing>

or:

<Testing>
  <Test><![CDATA[CITY & COUNTY]]></Test>
</Testing>
问题回答

第二个问题:有两张签名。 替换。 一种具有特征,另一种带有特征。 使用单一字句,试图打造特征字面——但C#“&amp”;实际上是一种扼杀(具有5个特性)。

它是否以双重引语开展工作?

editXml.Replace("&", "&amp;");

如果你想更保守的话,你也可以写成法典,以确保“灯”不会被你取代,而你则不采用“灯”。

amp; quot; apos; gt; lt; or #

(but this would still not be a perfect filtering)

在XML中指明一个营地,请使用&amp;。 自邮局签署(和;)以来,XML具有特别的意义。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签