forked from pvalente/thackday-opentables
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtb.xml
48 lines (44 loc) · 1.47 KB
/
tb.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" encoding="ISO-8859-1"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<description></description>
<sampleQuery>select * from {table} where nome="maluf"</sampleQuery>
</meta>
<bindings>
<select itemPath="lero.political" produces="XML">
<urls>
<url></url>
</urls>
<inputs>
<key id='nome' type='xs:string' paramType='variable' required="true" />
</inputs>
<execute><![CDATA[
var q = y.query('select content, href, strong from html where '
+ 'url="http://www.excelencias.org.br/@busca.php?nome='
+ nome +'" and xpath=\'//a\'');
var results = q.results;
var entries = <lero></lero>;
// defining vars to re-use on for loop
var id = null;
var fdp = null;
var partido = null;
for each(a in results.a){
var entry = <political></political>;
id = new RegExp("id=(\\d+)").exec(a); // search by id in entire a tag
id = id[1]; // get the second ocurrence
fdp = a.strong.text() + ' - ' + a.text() ; // get the text from tag strong
partido = new RegExp("- (.*)$").exec(a.text());
if (partido != null) {
partido = partido[1];
}
entry.appendChild(<id>{id}</id>); //
entry.appendChild(<nome>{fdp}</nome>);
entry.appendChild(<partido>{partido}</partido>);
entry.appendChild(<url>http://www.excelencias.org.br/candidatos/@candidato_n.php?id={id}</url>);
entries.appendChild(entry);
}
response.object = entries;
]]></execute>
</select>
</bindings>
</table>