【发布时间】:2010-12-31 16:57:53
【问题描述】:
我的任务是获取所有 SMS updates from this page 并使用 Yahoo Pipes 将它们放入 JSON 提要。我不完全确定如何获得每次更新,因为它们不是单独的元素,而只是标题的集合等。任何共享的智慧将不胜感激!
【问题讨论】:
标签: html xml json dom yahoo-pipes
我的任务是获取所有 SMS updates from this page 并使用 Yahoo Pipes 将它们放入 JSON 提要。我不完全确定如何获得每次更新,因为它们不是单独的元素,而只是标题的集合等。任何共享的智慧将不胜感激!
【问题讨论】:
标签: html xml json dom yahoo-pipes
<h1 id="blogtitle">SMS Update</h1>
<div class="blogposttime blogdetail">Left at 2nd January 2010 at 01:12</div>
<div class="blogcategories blogdetail">Recieved by SMS (Location: Pokhara - Nepal)</div>
<p class="blogpostmessage">
RACE DAY! We took the extra day off to pimp the rick some more, including a huge Australian flag. Quiet night at a pub with 6 other teams. Time for brekkie and then we're off to the rickshaw grounds for 8:30 for 10am start.
</p>
对于 DOM/XML 解析器来说,这似乎是一项相当容易的工作。
由于块没有包含在 XML 标记中,您可以查找每个块中存在的元素,例如 <h1 id="blogtitle">SMS Update</h1> 定义了新块的开始。
使用您的 DOM 解析器查找 ID 为 blogtitle 的所有元素。此时,您可以使用 DOM 函数来引用 blogtitle 元素的 nextSibling。您只需要 blogtitle 元素之后的 3 个兄弟姐妹。
通过一些工作,您可以轻松地使用此逻辑来构建您的 JSON 对象。
【讨论】: