HTML 到 XHTML Web 浏览器控件

发布于 2024-08-24 04:41:08 字数 832 浏览 12 评论 0原文

我一直在编辑模式下使用 .NET WebBrowser 控件作为最终用户界面的一部分,以创建 HTML 内容部分以插入到各种网站中。他们有一个非常精简的可用标签列表,例如


不幸的是,我现在需要将 xhtml 放入更大的 xml 文档中,以供其他各种网站进行聚合。 WebBrowser 的主要问题似乎是它产生的位置列表:

<UL><LI>Item1
<LI>item2 
<LI>item3</LI></UL>

是否有一个好的转换器库来解决此问题,或者我可以强制 WebBrowser 控件创建 XHTML?我已经尝试过 HTMLAgilityPack,但它通过执行以下操作转换为 XHTML:

<UL><LI>Item1
<LI>item2 
<LI>item3</LI></LI></LI></UL>

我认为他的设置不正确,因为标签肯定应该位于每个项目的末尾,尽管它会通过 xhtml 验证。如果可以的话,当 XML 最终放入任何网站时,我是否会在某些浏览器上遇到渲染问题?

I have been using the .NET WebBrowser control in edit mode as part of an interface for end users to create sections of HTML content for insertion into various websites. They have had a very cutdown list of tags available such as <p>, <br>, <a href>, <strong>, <ul> <li>... they could not apply any formatting on top of the tags as that was determined by the particular web pages css. This system has been working well up until now.

Unfortunately I now have a need for xhtml to go into a larger xml document for aggregation purposes by various other websites. The WebBrowsers main problem seems to be lists where it produces:

<UL><LI>Item1
<LI>item2 
<LI>item3</LI></UL>

Is there a good converter library to fix this or could I force the WebBrowser control to create XHTML? I have tried the HTMLAgilityPack but it converted to XHTML by doing something like:

<UL><LI>Item1
<LI>item2 
<LI>item3</LI></LI></LI></UL>

I don't think his is appropriately set as surely the

tags should be at the end of each item although it would pass xhtml validation. If it is ok, will I end up with rendering issues on certain browsers when the XML is eventually put into whatever website?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

路还长,别太狂 2024-08-31 04:41:08

您必须使用 Internet Explorer,这是我能想到的唯一不会关闭内容可编辑部分中的列表项标记的浏览器。此外,标签应该是小写的,这是另一个赠品。

值得检查的是您是否向浏览器发送了正确的文档类型,因为这可能会解决您的问题(即确保可编辑位绝对是 XHTML 页面)。除此之外,您可以通过具有一些自定义(ish)标记的纯文本可编辑区域和下面的预览区域来管理它。嗯...有点像 Stack Overflow。这样,您就可以创建所需的确切标记,而不是依赖浏览器生成的标记。

You must be using Internet Explorer, which is the only browser I can think of that doesn't close list-item tags in a content-editable section. Also, the tags ought to be lower case, which is the other give-away.

It is worth checking that you are sending the correct document-type to the browser as this may solve your problem (i.e. make sure the editable bit is definitely an XHTML page). Other than this, you could manage it by having a plain-text editable area with some custom(ish) mark-up and a preview area below. Erm... a bit like Stack Overflow. That way, you can create the exact mark-up you want, rather than relying on what a browser generates.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文