0

我想获取具有 rel='edit' 的链接的 href 值,我想知道我该怎么做。

<link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/****'/>
<link rel='edit' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/****'/>

我在尝试

this.url = entry.getElementsByTagName('link')[1].getAttribute('href');

但我得到了第一个链接的href。

谢谢。

编辑 :

现在我不明白的是,即使我确定我得到了正确的链接,href 值也不是我所期望的

<link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/**********/full/ba0fz'/>
<link rel='edit' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/**********/full/ba0fz/27mpei328jki4e'/>

我想要的是对我想要得到“27mpei328jki4e”的href 做一个正则表达式,但是我没有得到完整的url,而是得到了一个简短的url,你知道我为什么得到这个结果吗?无论我使用什么方法,queryselector 和 getElementsByTagName 都不是。

我的文档是 xml

<?xml version='1.0' encoding='UTF-8'?>
 <entry xmlns='http://www.w3.org/2005/Atom'    xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'>
 <id>************</id>
 <updated>2013-06-06T17:38:25.749Z</updated>
 <category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/>
 <title type='text'>30/05/2013 17:12:42</title><content type='text'>
 timeprocess: 01/01/1900, useroid: ICCOM-00000327, 
 </content>
 <link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/**********/full/ba0fz'/>
 <link rel='edit' type='application/atom+xml' href='https://spreadsheets.google.com/**********/full/ba0fz/27mpei328jki4e'/>
 <gsx:time>30/05/2013 17:12:42</gsx:time>
 <gsx:timeprocess>01/01/1900</gsx:timeprocess>
 <gsx:useroid>ICCOM-00000327</gsx:useroid>
 </entry>
4

1 回答 1

3

尝试使用查询选择器

document.querySelector('link[rel="edit"]');
于 2013-06-07T15:04:10.033 回答