简体   繁体   English

尝试使用Google Sheet中的IMPORTXML从XML提取图像URL

[英]Trying to extract image URLs from XML using IMPORTXML in Google Sheet

I have been working on a IMPORTXML formula in Google Sheets to export image URLS from an XML file for specific records. 我一直在研究Google表格中的IMPORTXML公式,以从XML文件导出图像URL以获得特定记录。 I have not had much luck with the XPath I have been trying due to the hierarchy of the records. 由于记录的层次结构,我对尝试使用的XPath不太满意。

Here is the URL for the XML file: http://www.roguerealestate.com/listings.xml 这是XML文件的URL: http : //www.roguerealestate.com/listings.xml

I have been able to extract all IDValues using the following formula: 我已经能够使用以下公式提取所有IDValue:

=IMPORTXML("http://www.roguerealestate.com/listings.xml","//Property/Identification/IDValue")

I now want to be able to select an IDValue from a list and have it return all Src tags for that IDValue 我现在希望能够从列表中选择一个IDValue,并让它返回该IDValue的所有Src标签

I was able to get all Src tags using this formula, just need help parsing it down to only show URLs for a specific IDValue: 我能够使用此公式获取所有Src标签,只需要帮助解析它就可以仅显示特定IDValue的URL:

=IMPORTXML("http://www.roguerealestate.com/listings.xml","//Property/Floorplan/File/Src")

Any help would be much appreciated, I am just learning Xpath. 任何帮助将不胜感激,我只是在学习Xpath。

解析图像我用

 =IMPORTXML("http://www.yoursite.com", "//img/@src") 

The following query will select all 'Src' elements from the 'Property' elements that have the '/Identification/IDValue' field set to 110212 or 110151: 以下查询将从“ / Identification / IDValue”字段设置为110212或110151的“属性”元素中选择所有“ Src”元素:

//Property[./Identification/IDValue[text()=110212 or text()=110151]]/Floorplan/File/Src

Please verify on http://xpather.com/1ZgDP5Wz if this works as expected (the provided XML file was shortened and pasted). 如果可以正常工作,请在http://xpather.com/1ZgDP5Wz上进行验证(所提供的XML文件已缩短并粘贴)。 You can click on the results on the right to scroll to the relevant parts of the source document. 您可以单击右侧的结果以滚动到源文档的相关部分。

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

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