我正在尝试解析一个 Apple plist 文件,我需要在其中获取一个数组节点。不幸的是,它唯一的唯一标识符是它前面的同级节点,<key>ProvisionedDevices</key>
.现在我最好的想法是使用 Java 的 XPATH 查询或 Node.indexOf
.
这是一个例子:
<plist version="1.0">
<dict>
<key>ApplicationIdentifierPrefix</key>
<array>
<string>RP8CBF4MRE</string>
</array>
<key>CreationDate</key>
<date>2010-05-10T11:44:35Z</date>
<key>DeveloperCertificates</key>
<array>
...
<key>ProvisionedDevices</key>
<array>
... // I need the Nodes here
</array>
</dict>
</plist>
谢谢!
最佳答案
这个有效:
def findArray(key: Elem, xml: Elem) = {
val components = xml \ "dict" \ "_"
val index = components.zipWithIndex find (_._1 == key) map (_._2)
index map (_ + 1) map components
}
关于xml - 如何使用 Scala 获取与唯一节点相邻的节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2803448/