2010/01/16

Adding Data Source

If you want to add your data source (RSS/ATOM feed, or HTML page), click a 'Data Source' on a top bar.

1. Input URL



Please input the URL where you want.
On the right side, help messages are available.
A 'Check' button works while the URL is for RSS/ATOM feeds. It may suggest fields and help your input.


2. The Expression


If A 'Check' button does not help us, we should input valid expression to the expression field.
The expression is a 'Selector' defined in CSS2.
It's usually used to select HTML fragments(=Tagged Elements) to apply a style.
In F's News Generator it's used to select them to build a page.
Usually the main content is enveloped in any html-tag.

Not so difficult!
The expression is simply a 'Tag Name'(body, div, h1, table, or more) in most simple case.
However, in most popular case, same tag-names appear many times in single HTML.

For example, following document has a secret where in '<div id="main">'.

<div id="head">The Secret</div>
<div id="main">
This is the most important thing. The secret of the world.<br/>
I'd say th....
</div>
<div id="foot">to be continue...</div>

There are 3 'div' tags. The main content has the ID; 'main'.
To select it, you use this expression.

div#main
Sharp; '#' is meaning the 'id'.
The ID is unique identifier. The ID shall to select a single element.

Let me see the next example.
Following image is a sample web page and its source.



The main content that you want is enveloped in '<div class="post-body entry-content">'.
Usually, the main content is in 'div' or 'p' tags. Here the envelope is '<div class="post-body entry-content">'.
So you just get this element by selector.

'class' is a general attribute where the name figures the tag's type out.
Despite it's common usage, you don't need to care that. The most important thing is how 'class' is usable to select a element.
In this case, the 'div' element has a class named 'post-body' and 'entry-content'.
Here is,

div.post-body

Dot; '.' is meaning a 'class'.

And so the expression is below,



The end.

0 件のコメント:

コメントを投稿