Skip to content

Instantly share code, notes, and snippets.

@yaronn
Created August 20, 2014 16:19
Show Gist options
  • Save yaronn/a4c25992beb92bd9c9fe to your computer and use it in GitHub Desktop.
Save yaronn/a4c25992beb92bd9c9fe to your computer and use it in GitHub Desktop.
var select = require('xpath.js')
, dom = require('xmldom').DOMParser
var xml = "<?xml version='1.0' encoding='UTF-8'?>"+
"<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'>"+
" <entry>"+
" <updated>2014-08-19T14:37:34.663Z</updated>"+
" <category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#spreadsheet'/>"+
" <title type='text'>Tmp SS</title>"+
" <content type='text'>Tmp SS</content>"+
" <link rel='http://schemas.google.com/spreadsheets/2006#worksheetsfeed' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/worksheets/1DkxkuNGoXt_Hhu0yvvL60MqJuQIzdov4fewfewfewfewb9H_ot9khto/private/full'/>"+
" <link rel='alternate' type='text/html' href='https://docs.google.com/spreadsheets/d/1DkxkufwefewfweNGoXt_Hhu0yvvL60MqJuQIzdov4b9H_ot9khto/edit'/>"+
" </entry>"+
"</feed>"
var doc = new dom().parseFromString(xml)
var nodes = select(doc, "//*[local-name()='entry']/*[local-name()='link' and @rel='http://schemas.google.com/spreadsheets/2006#worksheetsfeed']/@href")
console.log(nodes[0].value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment