首页 > 解决方案 > Xpath 查询以根据不同路径的值获取值(如果,那么...)

问题描述

这里对 xpath 完全陌生。对我放轻松。

我正在使用 wp-property import 并且能够成功连接到 RETS 服务器并下载属性。但是,每个属性的两个重要信息都在其他路径中找到并且没有下载:办公室名称和代理名称。

除了这两个元素之外,我已经收到了我需要的属性路径中的所有内容。在每个属性中,都有一个 [ListingOfficeID]。[listor_name] 是空白的(很遗憾)。

属性(名称)
属性(类)
ListingID (ID)
[ListingOfficeID](属性)
[listor_name](空白属性)

我必须将 [ListingOfficeID] 链接到 Office 节点中的正确 [OfficeID] 并提取其对应的 [account] 即名称。

Office(名称)
Office(类)
ListingOfficeID(ID)
[OfficeID](属性)
[帐户](属性)

在 wp-property 导入中,每个属性的 xpath 规则都很简单。你没有括号。但我只从一个节点拉。所以,我试图想出一条路径来匹配办公室 ID 并提取帐户值。

属性 xpath

我试过了:

listor_name = //Office/Office/[ListingOfficeID=OfficeID]/account

//Office/Office/ListingOfficeID/ [//Property/Property/ListingID/[ListingOfficeID]/[account]

//Office/Office/[@ListingOfficeID= //属性/属性/ListingID/[ListingOfficeID]]/[帐户]

/Office/Office/ListingOfficeID = [@[/Property/Property/ListingID/[@ListingOfficeID]]]/[@account]

但这些都行不通。

这是属性 XML 的示例:

属性 xml

我需要 [ListingOfficeID] 与 Office XML 中的 [OfficeID] 匹配,以提取相应的 [account]:

办公室 xml

这是属性表中的原始 XML: 原始 XML 属性

显示需要与 Office 表的 [OfficeID] 匹配的 [ListingOfficeID],以提取 [account] - 这是 office 原始 XML。

原始 xml 办公室

这是我认为应该有效但不可行的方法:/Office/Office[@OfficeID="/Property/Property/ListingOfficeID"]/account

标签: xmlxpathimport

解决方案


推荐阅读