本文介绍了以XML格式存储HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我可以在HTML节点中存储HTML标签吗?我需要一些 方式来分享新闻头条。由于头条新闻不同,因此仅存储标题和 链接将非常困难。如果可能的话,我该怎么做? Burnsy Hi, Is it possible for me to store HTML tags inside XML nodes? I need someway to share news headlines. Because the headlines differ in theirpresentsation, it would be very difficult to store simply the title andlink. If possible, how would I do this? Burnsy 推荐答案 如果HTML格式正确,你可以将它视为X(HT)ML,并将节点视为xml文档 - Joris Gillis( http://users.telenet.be/root-jg/me.html ) Vincit omnia simplicitas 保持简单 If the HTML is well-formed, you can treat it as X(HT)ML and at the nodes to your xml document --Joris Gillis (http://users.telenet.be/root-jg/me.html)Vincit omnia simplicitasKeep it simple 然后使用RSS 1.0或Atom 1.0 这是一个现成的轮子。 http://xml.coverpages.org/ni2005-07-15 -a.html Then use RSS 1.0 or Atom 1.0This is very much a ready-invented wheel. http://xml.coverpages.org/ni2005-07-15-a.html 这是有问题的(不可行的,所以,在我的巨大经验做什么 吧。 - 它可能是片段,而不是整个HTML文档。 - 如果它是一个片段,那么它可能有多个根e lements,或者非 。你可以用XML来操作它,但你必须小心使用片段工具,而不是节点树。 - 如果它是HTML,你不能保证良好的形式。即便相当好b / b 表现良好的HTML可以省略结束标签,特别是如果它是从较大页面任意选择的 。 - HTML实体的问题没有用XML声明。 - 外部提供的HTML将有垃圾 - 一天。 - HTML不是XML。将XML规则应用于它,例如最小化没有内容的非空元素(例如< script src =" foo">< / script>) 可以导致下游无法解决问题。 This is problematic (unworkably so, in my enormous experience of doingit). - It''s probably a fragment, not a whole HTML document. - If it is a fragment, then it may have multiple root elements, or nonat all. You can manipulate this in XML, but you have to be careful touse fragment tools on it, not node trees. - If it''s HTML, you just can''t guarantee well-formedness. Even quitewell-behaved HTML can omit closing tags, especially if it''s anarbitrary selection from a larger page. - There''s the issue of HTML entities that aren''t declared in XML. - Externally supplied HTML will have garbage in it - one day. - HTML isn''t XML. Applying XML rules to it, such as minimising anon-empty element with no content (like <script src="foo" ></script> )can cause no end of trouble downstream. 这篇关于以XML格式存储HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-25 17:49