2013-05-12 79 views
1

我希望将使用Yahoo Pipes的TR中的3个相邻TD元素的内容转换为以逗号分隔的值列表。来源:Epic Systems Hospitals从XPATH提取页面提取子元素管道

HTML片段:

...

<table width="623" cellspacing="0" cellpadding="0" border="0"> 
    <colgroup> 
    <tbody> 
     <tr height="20"> 
     <td width="425" height="20">Institution 0</td> 
     <td width="134">Minneapolis</td> 
     <td width="64">MN</td> 
     </tr> 
     <tr height="20"> 
     <td height="20">Institution 1</td> 
     <td>Philadelphia</td> 
     <td>PA</td> 
     </tr> 

...

我用 “的XPath抓取页面” 源使用XPath正确隔离TR元素= //tr[@height='20']

但是,我很难得到TD元素。对于我而言,我不知道应该使用哪个组件,所以我选择了使用'special variable substitution'语法的子元素。不幸的是,${td.0.content}不起作用。

我不理解什么?

**编辑**

我的目标是创建一个类似于XML流:

<institutions> 
    <institution name='Institution 0' city='Minneapolis' region='MN'/> 
    <institution name='Institution 1' city='Philadelphia' region='PA'/> 
    ... 
<institutions/> 

enter image description here

+0

从我的理解'xfetch'页面发出'html5'内容(​​如您已选择了该选项),也可以发出'strings' 。 “子元素”模块有助于从层次结构中获取数据,这些数据可以是XML或RSS源的形式。 – Bill 2013-05-12 19:19:15

+0

从我引用的页面:“目前这个模块将提取页面并使用Tidy修复格式错误的标签。”这不表示文档已被转换为XHTML吗? – craig 2013-05-13 11:51:57

回答

3

如果你总是有3个td单元格,你可以使用一个Loop运营商与String Builder里面,并通过连接item.td.0,item.td.1,item.td.2建立一个字符串。

我创造了这样一个例子你在这里:

http://pipes.yahoo.com/pipes/pipe.info?_id=3d24486f7c6e8413dc6252ef37c2f086

+0

似乎可以将值插入到HTML流中,但流不能被重写。它是否正确? – craig 2013-07-03 12:31:07

+1

是的,我也这么认为。无论如何,要小心,雅虎管道是非常麻烦的,所以不要指望一致和合理的行为。 – janos 2013-07-03 17:04:02