I’m struggling with the correct IMPORTXML formula to extract data from an XML feed. I need to get a specific quantity value from this structure:
<?xml version="1.0" encoding="utf-8"?>
<gameapi version="2">
<timestamp>2017-01-02 11:59:29</timestamp>
<data>
<status>4</status>
<statusTime>2017-01-02 12:13:29</statusTime>
<lastOnline>2016-12-16 03:13:10</lastOnline>
<configuration>
<permissions>3</permissions>
<deployment>0</deployment>
<corporateAccess>1</corporateAccess>
<allianceAccess>1</allianceAccess>
</configuration>
<battleSettings>
<standingsSource playerID="99005805"/>
<standingThreshold level="0"/>
<statusAction active="0" level="0"/>
<aggressionResponse active="0"/>
<warResponse active="1"/>
</battleSettings>
<resources name="materials" key="itemID" columns="itemID,amount">
<item itemID="16275" amount="9300"/>
<item itemID="4051" amount="12140"/>
</resources>
</data>
<expires>2017-01-02 12:37:11</expires>
</gameapi>
I want to pull the amount value (12140) from the item where itemID equals “4051”. I’ve attempted several xpath expressions but none work correctly. What’s the proper syntax for this specific extraction?