Home Backend Development PHP Tutorial 如何用PHP把RDF内容插入Web站点之中_PHP

如何用PHP把RDF内容插入Web站点之中_PHP

Jun 01, 2016 pm 12:35 PM
h id li content Can how insert site

名誉和巨大的财富

设想一个从最热门的门户网站获得最新的新闻的站点。股票价格天气信息新闻故事线式讨论组软件发布……所有这一切都将被动态更新每小时一次不需要任何手工干预。我们可以想象这随之而来的站点访问量源源不断的广告收入以及网管大人所受到的“阿谀奉承”。

但是现在停止幻想开始阅读因为只要你密切关注此项技术说不定你就能成为站点的主人。 对你的要求也只是稍许的想象力一些聪明的PHP编码和几个免费的RSS文件。另外很明显还包括这篇文章剩下的九个部分。



有内容就联合成辛迪加Have Content, Will Syndicate
我们从最基本的开始——那么RSS究竟是什么鬼东西呢

RSS即RDF Site Summary是一种格式最早由Netscape公司设计用于分发其门户站点My.Netscape.Com上的内容的描述信息。自1997年被提出以来几经沉浮——可以点击文章末尾的链接了解一下RSS悠久复杂的历史。现在的稳定的版本是RSS1.0符合RDF规范。这一版本可以说即轻便又功能齐全。

RSS使得网管及时公布和分发某一特定站点的特定位置的最新最有趣的内容的描述信息变的可能。 从新闻文章列表到股票市场数据或着是天气预报所有这些信息都可以通过结构良好的XML文档来发布从而也可以被任何XML分析器进行分析处理和翻译。

网站上最新信息的列表是经常更新的而RSS使得这一列表的分发成为可能也就为Web上简易的内容辛迪加联合打开了大门。想了解这其中的道理请看下面这个简单的例子

站点A属新闻站点“内容辛迪加组织者”能够每小时发布一个包含最新新闻列表以及相应链接的RSS文档。 而这一RSS文档可以被其它站点获取如站点B“内容收集者”分析并显示在站点B的索引页面上。 每次站点A发布一个新的RSS文档站点B的索引页面都可以自动更新以获取最新的新闻。

这种方案对交易中的双方机构都有效。 既然RSS文档中的链接都指向站点A上相应的文章那么站点A将迅速体验到访问量的增加。 而站点B的网管可以休假一个星期因为他有办法自动更新其站点上的索引页面而这一方法仅仅是把索引页面与站点A发布的动态内容相连接而已。

有许多受欢迎的站点向公众提供详细的RSS或RDF新闻如Freshmeathttp://www.freshmeat.net)和Slashdot(http://www.slashdot.org),当然还有其它许多站点。在这篇文章当中,我将广泛的使用Freshmeat网站的RDF文件。需要说明的一点是,这里所谈到的技术也可以应用于其它任何RSS1.0或RDF文件。



交换频道(Switching Channels)

典型的RSS文档包含一个由描述性元数据标记出来的资源列表(URLs),请看下面的例子:

?>
rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns
="http://purl.org/rss/1.0/">

channel rdf:about="http://www.melonfire.com/">
title>Trog/title>
description>Well-written technical articles and
tutorials on Web technologies/description>

link>http://www.melonfire.com/community/columns/trog/


  • rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =100" />
  • rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =71" />
  • rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =62" />




    rdf:about="http://www.melonfire.com/community/columns/trog/article.php?i
    d=10
    0">
    Building A PHP-Based Mail Client (part 1)

    http://www.melonfire.com/community/columns/trog/article.php?id=100

    nk>
    Ever wondered how Web-based mail clients
    work? Find out here.



    rdf:about="http://www.melonfire.com/community/columns/trog/article.php?i
    d=71">
    Using PHP With XML (part 1)

    http://www.melonfire.com/community/columns/trog/article.php?id=71/link>
    Use PHP's SAX parser to parse XML data and
    generate HTML pages.



    rdf:about="http://www.melonfire.com/community/columns/trog/article.php?i
    d=62">
    Access Granted

    http://www.melonfire.com/community/columns/trog/article.php?id=62/link>
    Precisely control access to information
    with the mySQL grant tables.



    你可以看到,RDF文件由几个界限分明的部分组成。首先是文档序码(prolog),

    ?>

    然后是根元素中的名称空间声明。

    rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://purl.org/rss/1.0/">
    接着是channel>部分这部分包含了RDF所要描述的频道的一般信息。在上面的例子中频道是Melonfire网站的Trog专栏专栏内容是新的技术文章和指南每星期更新一次。

    channel rdf:about="http://www.melonfire.com/">
    title>Trog/title>
    description>Well-written technical articles and
    tutorials on Web technologies/description>

    link>http://www.melonfire.com/community/columns/trog//link>
    items>
    rdf:Seq>
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =100"
    />
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =71"
    />
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =62"
    />
    /rdf:Seq>
    /items>
    /channel>

    channel>区包含了一个items>区块items>区块又包含了文档中描述的所有资源的一个顺序列表。该列表通过一系列的li />元素来表示。区块中每一个资源都在后面的item>区块中有更详细的描述。

    items>
    rdf:Seq>
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =100"
    />
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =71"
    />
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =62"
    />
    /rdf:Seq>
    /items>

    还可以在其中放置一个image>区块这样你就可以发布频道标志的URL。

    所以为了肉RSS1.0文档中的每一个item>区块都更详细地描述一个单独的资源包括标题URL和资源描述。

    items>
    rdf:Seq>
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =100"
    />
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =71"
    />
    li
    rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph
    p?id
    =62"
    />
    /rdf:Seq>
    /items>

    在这个例子里item>区块描述了Ttrog“频道”中单独的一篇文章并为这篇文章提供了描述和标题以及URL。内容收集者可以利用URL创建“向后”链接。



    你看得到RSS1.0文件相当地直观明了不管是手工还是通过编程都非常容易创建。上面的例子和解释仅仅是说明性质的通常你可以用RSS1.0和RDF做更多的事情。你最好看一下文章末尾提供的链接以获取更多的信息。不过在这之前我们再花几分钟讨论一如何将RSS1.0文档插入到你自己的Web站点之中。

  • Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: How To Unlock Everything In MyRise
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    This Apple ID is not yet in use in the iTunes Store: Fix This Apple ID is not yet in use in the iTunes Store: Fix Jun 10, 2024 pm 05:42 PM

    When logging into iTunesStore using AppleID, this error saying "This AppleID has not been used in iTunesStore" may be thrown on the screen. There are no error messages to worry about, you can fix them by following these solution sets. Fix 1 – Change Shipping Address The main reason why this prompt appears in iTunes Store is that you don’t have the correct address in your AppleID profile. Step 1 – First, open iPhone Settings on your iPhone. Step 2 – AppleID should be on top of all other settings. So, open it. Step 3 – Once there, open the “Payment & Shipping” option. Step 4 – Verify your access using Face ID. step

    Fix event ID 55, 50, 98, 140 disk error in event viewer Fix event ID 55, 50, 98, 140 disk error in event viewer Mar 19, 2024 am 09:43 AM

    If you find event ID 55, 50, 140 or 98 in the Event Viewer of Windows 11/10, or encounter an error that the disk file system structure is damaged and cannot be used, please follow the guide below to resolve the issue. What does Event 55, File system structure on disk corrupted and unusable mean? At session 55, the file system structure on the Ntfs disk is corrupted and unusable. Please run the chkMSK utility on the volume. When NTFS is unable to write data to the transaction log, an error with event ID 55 is triggered, which will cause NTFS to fail to complete the operation unable to write the transaction data. This error usually occurs when the file system is corrupted, possibly due to the presence of bad sectors on the disk or the file system's inadequacy of the disk subsystem.

    How to add trusted sites in Google Chrome How to add trusted sites in Google Chrome Jul 19, 2024 pm 04:14 PM

    How to add trusted sites in Google Chrome? Some users cannot browse the web normally because the page prompts that it is not secure when surfing the Internet. At this time, they can add the website as a trusted site, and we can access it normally and surf the Internet smoothly. The editor below will bring you the steps to add a trusted site in Google Chrome. The steps are simple and easy to operate, and even beginners can easily get started. Friends who need it can learn about it together. How to add a trusted site in Google Chrome: 1. Open Google Chrome and click the three dots in the upper right corner. Click [Settings]. Choose privacy settings and security. (As shown in the picture) 2. Click Website Settings at the bottom of the page. (As shown in the picture) 3. Click on the unsafe content at the bottom of the page. (As shown in the picture) 4. Click the Add button to the right of the Allow option. (As shown in the picture) 5. Lose

    How to enable Sensitive Content Warning on iPhone and learn about its features How to enable Sensitive Content Warning on iPhone and learn about its features Sep 22, 2023 pm 12:41 PM

    Especially over the past decade, mobile devices have become the primary way to share content with friends and family. The easy-to-access, easy-to-use interface and ability to capture images and videos in real time make it a great choice for creating and sharing content. However, it's easy for malicious users to abuse these tools to forward unwanted, sensitive content that may not be suitable for viewing and does not require your consent. To prevent this from happening, a new feature with "Sensitive Content Warning" was introduced in iOS17. Let's take a look at it and how to use it on your iPhone. What is the new Sensitive Content Warning and how does it work? As mentioned above, Sensitive Content Warning is a new privacy and security feature designed to help prevent users from viewing sensitive content, including iPhone

    Using the MINUS operator in SQL Using the MINUS operator in SQL Feb 18, 2024 pm 04:53 PM

    Usage of MINUS in SQL and specific code examples In SQL, MINUS is an operator used to perform a difference operation between two result sets. It is used to delete the same rows from the first result set as in the second result set. The result set returned by the MINUS operator will contain rows that exist only in the first result set. The following uses specific code examples to demonstrate the usage of MINUS: Assume there are two tables - "table1" and "table2", their structures are as follows: Table name: table1 field

    Where can I find Alibaba ID? Where can I find Alibaba ID? Mar 08, 2024 pm 09:49 PM

    In Alibaba software, once you successfully register an account, the system will assign you a unique ID, which will serve as your identity on the platform. But for many users, they want to query their ID, but don't know how to do it. Then the editor of this website will bring you detailed introduction to the strategy steps below. I hope it can help you! Where can I find the answer to Alibaba ID: [Alibaba]-[My]. 1. First open the Alibaba software. After entering the homepage, we need to click [My] in the lower right corner; 2. Then after coming to the My page, we can see [id] at the top of the page; Alibaba Is the ID the same as Taobao? Alibaba ID and Taobao ID are different, but the two

    How to change the Microsoft Edge browser to open with 360 navigation - How to change the opening with 360 navigation How to change the Microsoft Edge browser to open with 360 navigation - How to change the opening with 360 navigation Mar 04, 2024 pm 01:50 PM

    How to change the page that opens the Microsoft Edge browser to 360 navigation? It is actually very simple, so now I will share with you the method of changing the page that opens the Microsoft Edge browser to 360 navigation. Friends in need can take a look. I hope Can help everyone. Open the Microsoft Edge browser. We see a page like the one below. Click the three-dot icon in the upper right corner. Click "Settings." Click "On startup" in the left column of the settings page. Click on the three points shown in the picture in the right column (do not click "Open New Tab"), then click Edit and change the URL to "0" (or other meaningless numbers). Then click "Save". Next, select "

    Where to check Tencent Video ID Where to check Tencent Video ID Feb 24, 2024 pm 06:25 PM

    Where can I check the Tencent Video ID? There is an exclusive ID in the Tencent Video APP, but most users do not know how to check the Tencent Video ID. Next is the graphic tutorial on how to check the Tencent Video ID brought by the editor for users who are interested. Users come and take a look! Tencent Video Usage Tutorial Where to check Tencent Video ID 1. First open the Tencent Video APP and enter the special area through [Personal Center] in the lower right corner of the main page; 2. Then enter the Personal Center page and select the [Settings] function; 3. Then go to Settings page, click [Exit Account] at the bottom; 4. Finally, you can view the exclusive ID number on the page shown below.

    See all articles