使用xpath将importxml导入google电子表格会返回FALSE [英] importxml to google spreadsheet with xpath returns FALSE
问题描述
我正在尝试构建一个spreedsheet,它能够从远程存储的xml文件中提取数据. xml具有以下结构:
I'm trying to build a spreedsheet which is able to pull data from an remotely stored xml file. The xml has the following structure:
<response>
<content>
<measurements>
<measurement>
<from>2017-12-11T01:00:00+01:00</from>
<to>2017-12-11T02:00:00+01:00</to>
<values>
<value label="fw">19</value>
<value label="bw">0</value>
</values>
</measurement>
and so on ...
我尝试使用label ="fw"提取值,但是在使用以下语法或类似语法时,它仅返回FALSE或#N/A
I try to extract the values with the label="fw" but it returns only FALSE or #N/A when using the following or a similiar syntax
={
IMPORTXML(A1,"//*[name()='"&A2&"']/value/@label='fw'")
}
A1是URL( http://someurl.de/dir1/count-data_countdata_D8-80-39-D3-DD-C8_2017-12-12-01-00-00.xml -清除了真实的路径)
A1 is the URL (http://someurl.de/dir1/count-data_countdata_D8-80-39-D3-DD-C8_2017-12-12-01-00-00.xml - blanked out the real path)
A2 =值
XML是<?xml version='1.0' encoding='UTF-8'?>
URL之所以有效,是因为我只尝试一次
The URL is working because when I only try
={
IMPORTXML(A1,"//*[name()='"&A2&"']")
}
它返回两列的值:
0 0
0 0
0 0
0 0
0 0
0 0
4 0
9 1
49 1
133 6
151 18
150 11
107 5
101 4
75 5
108 9
111 17
125 46
107 65
26 23
2 0
0 0
0 0
0 0
我在做什么错了?
推荐答案
这个怎么样?您可以使用value[@label='fw']
检索值.
How about this? You can retrieve the value using value[@label='fw']
.
=IMPORTXML(A1,"//*[name()='"&A2&"']/value[@label='fw']")
如果这不起作用,对不起.
If this didn't work, I'm sorry.
=IMPORTXML(A1,"//*[local-name()='value'][@label='fw']")
这篇关于使用xpath将importxml导入google电子表格会返回FALSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!