Brandon Chiu
Brandon Chiu

Reputation: 33

Getting a xPath from XML document

I am trying to get some values from an online XML document, but I cannot find the right xpath to navigate to those values. I want to import these values into a Google Spreadsheet document, which requires me to get the exact xpath.

The website is this one, and I am trying to get the information for "WillPay" information from MeetingInfo Venue=S1, Races RaceNo=1, Pools PoolInfo Pool=WIN, in OddsInfo.

For now, the value of "Number=1" should be 3350 (or something close to this, it changes quite often), and I would like to load all of these values onto the google spreadsheet document.

What I've tried is locating the xpath of all of it, and tried to my best attempt to get

"/AOSBS_XML/Meetings/MeetingInfo/Races/Pools/PoolInfo/OddsSet/OddsInfo/@WillPay"

but it doesn't work.

I've been stuck on this problem for months now and I've been avoiding it, but realised I can't anymore because it's hindering my work. Please help.

Thanks! -Brandon

Upvotes: 3

Views: 156

Answers (2)

E.Wiest
E.Wiest

Reputation: 5915

An alternative :

//OddsInfo[@WillPay][ancestor::PoolInfo[@Pool='WIN'] and ancestor::RaceInfo[@RaceNo='1'] and ancestor::MeetingInfo[@Venue='S1']]

Upvotes: 0

Jack Fleeting
Jack Fleeting

Reputation: 24930

Try using this xpath expression:

//MeetingInfo[@Venue="S1"]/Races//RaceInfo[@RaceNo="1"]//Pools//PoolInfo[@Pool="WIN"]//OddsSet//OddsInfo[@Number="1"]/@WillPay

Upvotes: 1

Related Questions