Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
google文档上的IMPORTXML语法_Xml_Xpath - Fatal编程技术网

google文档上的IMPORTXML语法

google文档上的IMPORTXML语法,xml,xpath,Xml,Xpath,我尝试了多种不同的语法格式,试图从这个XML API中提取特定的值: <?xml version="1.0" encoding="utf-8"?> <eveapi version="2"> <currentTime>2017-01-02 11:59:29</currentTime> <result> <state>4</state> <stateTimesta

我尝试了多种不同的语法格式,试图从这个XML API中提取特定的值:

<?xml version="1.0" encoding="utf-8"?>
<eveapi version="2">
    <currentTime>2017-01-02 11:59:29</currentTime>
    <result>
        <state>4</state>
        <stateTimestamp>2017-01-02 12:13:29</stateTimestamp>
        <onlineTimestamp>2016-12-16 03:13:10</onlineTimestamp>
        <generalSettings>
            <usageFlags>3</usageFlags>
            <deployFlags>0</deployFlags>
            <allowCorporationMembers>1</allowCorporationMembers>
            <allowAllianceMembers>1</allowAllianceMembers>
        </generalSettings>
        <combatSettings>
            <useStandingsFrom ownerID="99005805"/>
            <onStandingDrop standing="0"/>
            <onStatusDrop enabled="0" standing="0"/>
            <onAggression enabled="0"/>
            <onCorporationWar enabled="1"/>
        </combatSettings>
        <rowset name="fuel" key="typeID" columns="typeID,quantity">
            <row typeID="16275" quantity="9300"/>
            <row typeID="4051" quantity="12110"/>
        </rowset>
    </result>
    <cachedUntil>2017-01-02 12:37:11</cachedUntil>
</eveapi>

2017-01-02 11:59:29
4.
2017-01-02 12:13:29
2016-12-16 03:13:10
3.
0
1.
1.
2017-01-02 12:37:11
我要寻找的值是这行的数量:

<row typeID="4051" quantity="12140"/>


谢谢你,我已经尝试了多种方法,但我似乎无法得到它

下面的XPath将查找
元素,其中
类型ID
属性等于4051,然后返回相应的
数量
属性值:

=importxml("URL here...", "//row[@typeID='4051']/@quantity")

如果要选择此行的值(为空)

如果您只想获取
行/@typeID
节点的
数量
属性的属性值,可以使用这个更简单的表达式

//row[@typeID='4051']/@quantity

它将使用给定的XML返回“12110”。

因此,我从
//行[@typeID='4051']/@quantity]得到的返回是“导入的内容为空”,因此它不会将值返回到我的工作表中。我试着使用这两种表达,得到了同样的结果。这是我想要显示的值。因此,我得到一个“导入内容为空”的值,我希望它返回该行的数量值。知道为什么没有吗?
//row[@typeID='4051' and @quantity='12110']/text()
//row[@typeID='4051']/@quantity