importXML中的Xpath命令

时间:2014-07-12 16:35:33

标签: xpath google-sheets

我需要一些帮助来获取ImportXML命令以返回我正在寻找的结果。 我正在使用Google表格。

我使用的XML看起来像这样:

<DocumentElement>
    <BuyOrder>
        <itemName>Name of item 1</itemname>
        <itemID>1</itemID>
        <maxPrice>1000</maxPrice>
        <quantity>100</quantity>
    </BuyOrder>
    <BuyOrder>
        <itemName>Name of item 2</itemname>
        <itemID>2</itemID>
        <maxPrice>2000</maxPrice>
        <quantity>200</quantity>
    </BuyOrder>
</DocumentElement>

等等。

我需要的是一个XPath表达式,我可以使用它来获取特定maxPrice上的itemIDitemID的ID来自工作表中的另一个单元格。

2 个答案:

答案 0 :(得分:0)

我认为这个xpath会帮助你

xpath = "//itemID[contains(.,'1')]/following-sibling::maxPrice"

答案 1 :(得分:0)

尝试以下内容:

//DocumentElement/BuyOrder[itemID=2]/maxPrice

http://www.w3schools.com/XPath/xpath_examples.asp有一些很好的学习XPath的例子。他们还有一个在线XPath测试员。

http://www.xpathtester.com/xpath是另一个在线XPath测试人员。

相关问题