Google Spreadsheets has an IMPORTXML function, which I am trying to use to maintain a list of TV episodes, based on the API at http://services.tvrage.com/feeds/episode_list.php?sid=3183.
I am trying to get a table of Date | Season No | Episode No | Title
from that XML.
The XML is hierarchical, nesting episodes under seasons.
I can get my date, episode and title columns, using xpath:
- Date -
/Show/Episodelist/Season/episode/airdate
- Episode No -
/Show/Episodelist/Season/episode/seasonnum
- Title -
/Show/Episodelist/Season/episode/title
However, I cannot get seem to find the right xpath to extract the Season number for each episode entry, which is the no
attribute to the Season
parent node.
I have tried:
/Show/Episodelist/Season/episode/../@no
/Show/Episodelist/Season/episode/parent::Season/@no
Both of these result in getting a distinct list of seasons, i.e.:
Date Season Episode Title
01-01-2001 1 1 foo
02-01-2001 2 2 bar
03-01-2001 3 3 baz
04-01-2001 4 fee
05-01-2001 5 fob
01-03-2002 1 bix
02-03-2002 2 buz
03-03-2002 3 fez
04-03-2002 4 baj
...whereas I am looking for:
Date Season Episode Title
01-01-2001 1 1 foo
02-01-2001 1 2 bar
03-01-2001 1 3 baz
04-01-2001 1 4 fee
05-01-2001 1 5 fob
01-03-2002 2 1 bix
02-03-2002 2 2 buz
03-03-2002 2 3 fez
04-03-2002 2 4 baj
What is the correct xpath so that the IMPORTXML routine does not do a distinct operation on the imported data?