English 中文(简体)
带有html的XML或X射线内容编码或脱光特征
原标题:Loading XML or XHTML content with html encoded or escaped characters

I m 为内容管理系统开发一个班级。 投入内容以X超文本格式提供。 并且可以包含诸如<代码>&第163号;等有效的越生特性。 见下文。

<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head xmlns="">
    <meta name="Attr_DocumentTitle" content="Hello World Books" />
   </head>
  <body>

 <div>British Pound   &#163;</div>

 <div>Registered sign &#174;</div>

 <div>Copyright sign &#169; </div>

  </body>
</html>

我的目标是用一种方法把这种方法装上XML。 净物体进行一些处理,并节省了数据库。 我想保持其越狱的性质。 我的方法是:

public static XmlDocument LoadXmlFromString(string xhtmlContent)
{
    byte[] xhtmlByte = Encoding.ASCII.GetBytes(xhtmlContent);
    MemoryStream mStream = new MemoryStream(xhtmlByte);
    XmlReaderSettings settings = new XmlReaderSettings();
    //Upon loading XML, prevent DTD download, which would be blocked by our 
    //firewall and generate "503 Server Unavailable" error.
    settings.XmlResolver = null;
    settings.ProhibitDtd = false;
    XmlReader reader = XmlReader.Create(mStream, settings);
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(xhtmlContent);
    return xmlDoc; //Value of xmlDoc.InnerXml contains £ ® © in place 
                    // of &#163; &#174; and &#169;
}

然而,这种方法将越狱的品格转换为同类物。 我如何能够避免这种情况,保持越狱的风气。

最佳回答
问题回答

暂无回答




相关问题
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. ...

热门标签