简体   繁体   English

Google文档上的IMPORTXML语法

[英]IMPORTXML Syntax on google docs

I have tried multiple different formats for the syntax I am trying to pull a specific value from this XML API: 我尝试了多种不同格式的语法,试图从此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>

The value I'm looking for is the Quanity on this line: 我要寻找的值是这行上的Quanity:

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

Thank you, I've tried multiple ways and I cant seem to get it. 谢谢,我已经尝试了多种方法,但似乎无法理解。

以下XPath将查找typeID属性等于4051的row元素,然后返回相应的quantity属性值:

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

If you want to select the value of this line (which is empty ) 如果要选择此行的值(为

<row typeID="4051" quantity="12110"/>   <!-- I fixed the value from 12140 to 12110 -->

you could use this XPath expression: 您可以使用以下XPath表达式:

//row[@typeID='4051' and @quantity='12110']/text()

If you just want to get the attribute value of the quantity attribute of the row/@typeID node, you could use this simpler expression 如果只想获取row/@typeID节点的quantity属性的属性值,则可以使用以下更简单的表达式

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

which would return '12110' with your given XML. 它将使用您给定的XML返回“ 12110”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM