如何将HTML文档存储在数据库中? [英] How do you store HTML documents in a database?

查看:127
本文介绍了如何将HTML文档存储在数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用锚来创建一个HTML文档(网页),并将该文件保存在某处,另一个程序将通过它们的URL链接到这些文档,并在末尾使用锚语法,以便将它们定向到正确的部分的文件。



做这件事的最好方法是什么?我是否以编程方式生成HTML文档并插入定位点,然后让用户将此文档保存在其服务器上?我将如何获得该文档位置的URL?我正在使用ASP.NET。

或者,我是否只使用HTML文本编辑器将HTML保存为SQL数据库中的varchar(MAX)。但是,如果我这样做,我该如何添加锚点?AND,如何在浏览器中读取HTML时将其作为长字符串存储在数据库中(我还没有找到任何知道答案的人) ?我尝试过LITERALS和iFRAME,但都没有从数据库中呈现HTML内容。

我认为最好的方法是用编程方式生成HTML文档,这样我就可以控制输入锚点(我认为这不可能与Ajax HTML编辑器)。然后让用户将此文档(网页)保存在他们想要的计算机/服务器上。然后,如果我有URL,可以通过知道其位置的URL来让其他程序转到该文档的锚点。

方案

好吧,回答你的问题有几个不同的部分,但我认为我可以帮助你(如果我误解了你的问题,我就道歉)。



过去,我不得不做一些有限的网络工作,而一个似乎对我来说一直工作的解决方案是构建整个网页,布局和所有没有内容。从那里,将所有文本存储到Sql数据库中的varChar插槽中。这同样适用于存储URL,所以这是解决你的锚点问题的一个可能的解决方案(这是我跟踪图片URL的方式)。



至于存储数据库中的实际页面,我不确定这是可能的,或者即使可以,也是可取的。只需像其他一切那样将页面存储在服务器上即可。过去,用于在页面和服务器之间存储和加载数据的简单后端就是您需要使系统启动并运行的所有功能。

由于您使用的是ASP,我不是100%确定sql交互是多么困难,但在PHP中这是一项非常简单的任务。事实上,我已经设计并部署了基于PHP的接口客户端,如果您需要它,我很乐意与您分享 - 只需向我发送一条消息即可。希望这有助于至少有点,我知道答案是模糊的,但问题是复杂的。


I need to create an HTML document (webpage) with anchors, and have that file saved somewhere, another program will be linking to these documents via their URL with the anchor syntax at the end so that they are directed to the correct part of the document.

What is the best way to do this? Do I programmatically generate the HTML document and insert the anchor points, then get the user to save this document on their server? How would I get the URL to the location of this document? I am using ASP.NET.

Or, do I just use an HTML text editor to save the HTML as a varchar(MAX) in the SQL database. BUT, if I do this, how can I add the anchors?AND, how can I read the HTML in a browser when it is stored as a long string in the database (I have yet to find anyone who knows the answer to that)? I have tried LITERALS and iFRAME but neither render the HTML content from the database.

I am thinking the best way is to programmartically generate the HTML document, this way I have control over entering anchor points (I don't think this is possible with the Ajax HTML editor). Then simply have the user save this document (webpage) anywhere they want on their computer/server. Then, if I have the URL, I can get this other program to go to that document, at the anchor point, by knowing the URL of its location.

解决方案

Well, there are several different parts to answering your question, but I think I might be able to help (if I've misunderstood your question then I apologize).

In the past I've had to do some limited web work and a solution that always seemed to work for me was to build your entire web page, layout and all, just without the content. From there, store all the text into varChar slots in a Sql database. This works equally well for storing URLs, so that is a possible solution to your anchors problem (this is how I kept track of image URLs).

As far as "storing" the actual pages in a database, Im not sure that's possible, or desirable even if you could. Just store the pages on the server like everything else. Past that, a simple back end used to store and load data between the page and the server is all you need to get a system like that up and running.

Since you're using ASP, I'm not 100% sure how difficult sql interaction is, but in PHP it is a very easy task. In fact, I have already designed and deployed a PHP based interfacing client that I'd be happy to share with you if you need it - just shoot me a message. Hope this helps at least somewhat, I know the answer was vague, but the question is a complex one.

这篇关于如何将HTML文档存储在数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆