xml - 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 并提取帐户值。
我试过了:
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 的示例:
我需要 [ListingOfficeID] 与 Office XML 中的 [OfficeID] 匹配,以提取相应的 [account]:
这是属性表中的原始 XML: 原始 XML 属性
显示需要与 Office 表的 [OfficeID] 匹配的 [ListingOfficeID],以提取 [account] - 这是 office 原始 XML。
这是我认为应该有效但不可行的方法:/Office/Office[@OfficeID="/Property/Property/ListingOfficeID"]/account
解决方案
推荐阅读
- python - 如何从 Pyhton 的类中只获取一个对象
- django - Django & GDAL - 找不到 GDAL 库
- opencv - 来自 Unity 的相机内在矩阵
- kotlin - 在 OpenShift 中部署的容器中运行多个协程
- nette - Nette - 导入 naja 库
- java - 与 Azure Postgres DB 断开连接
- mongodb - 在 MongoDB yml 中执行命令
- git - 在 Gitlab 上自动合并 Master 到 Develop
- python - 找出列表中的所有组合但不能重复
- java - 如何在Java中使用增强的for循环获取linkedhashmap的下一个键/值对