xml – 如何使用Scala将节点与独特节点相邻?

我正在尝试解析Apple plist文件,我需要在其中获取一个数组Node.不幸的是,它唯一的唯一标识符是它之前的同级节点,< 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
}

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念