HTML 到 XHTML Web 浏览器控件
我一直在编辑模式下使用 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个。
http://tidy.sourceforge.net/
Try this.
http://tidy.sourceforge.net/
您必须使用 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.