大家好!
今天要實作能輸入網址的 RSS 閱讀器。
我們進入今天的主題吧!
Felix('form').on('submit', function (e) {
    e.preventDefault();
    Felix.xhr('GET', Felix('#url')[0].value, {
        load: function () {
            if (this.readyState !== 4 || this.status !== 200) return;
            Felix('body').insert(RSS2HTML(this.responseXML).documentElement);
        }
    });
});
function replace(str, oldEl) {
    const newEl = Felix.create(str, oldEl.innerHTML);
    oldEl.parentNode.replaceChild(newEl, oldEl);
    return newEl;
}
function RSS2HTML(rss) {
    const els = [].slice.call(rss.querySelectorAll('*')).reverse();
    els.forEach(function (el) {
        replace(`div.${el.tagName}`, el);
    });
    return rss;
}
<body>
    <form>
        <input type="text" id="url" required>
        <button type="submit">Submit</button>
    </form>
</body>
範例連結製作中。
差不多也到尾聲了。
如果對文章有任何疑問,也歡迎在下方提問和建議!
我是 Felix,我們明天再見!