English 中文(简体)
XML CDATA 内读取和操纵 HTML
原标题:Reading and Manipulating HTML inside XML CDATA
  • 时间:2012-05-22 16:14:57
  •  标签:
  • c#
  • xml
  • cdata

当我从 XML CDATA 区域中抓取 HTML 时, 操作它( 以我为例, 在 CDATA 区域文本中执行 C# 字符串方法), 然后显示经编辑的版本... 它自动评论我的第一个 HTML 标记 :

<![CDATA[ <p>Lorem ipsum dolor sit amet...</p> ]]>

转换到页面上的此值 :

<!--[CDATA[ <p--> Lorem ipsum dolor sit amet... ]]>

它打破了第一段的样式,并将关闭的 CDATA 标记置于内容之后。

我该如何解决这个问题?

EDIT: I couldn t find anything about this, so I tried a few things for poos and giggles, and this worked:

<![CDATA]> <p>Lorem ipsum dolor sit amet...</p> </]]>

转换到此页面上的 :

<!--[CDATA]--> <p>Lorem ipsum dolor sit amet...</p> <!--]]-->

但我不确定这是否会对我页面造成负面的影响?

还有别的办法吗?

最佳回答

当在包含 CDATA 的 XML 元素上使用 < code> XmlNode. InnerXml 时, 它会评论第一个元素 。

使用 XmlNode. InnerText 。 CDATA 将有效 。

如果您的 必须 使用 InnerXml... 您可以省略 CDATA 标签, 它也会有效 。

如果您需要 < ennerXml 和 CDATA 都 < ennerXml 和 < ennerXml 和 CDATA 都 < ennerXml 和 enerXml 和 CDATA 都 < 坚固 >, 我找不到答案... 或两者一起使用的设想

问题回答

暂无回答




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

热门标签