我正在尝试快速获取 XML 节点中属性的值。下面是一个代码示例。我看不到任何获取值的方法,因为似乎没有属性或方法允许这样做。
for word in dictionary.words {
let xpath = "/strongsdictionary/entries/entry[greek[@unicode='" + word.word + "']]/pronunciation"
do {
let xmlnode = try document?.nodes(forXPath: xpath )
// Need to get value of attribute named 'strongs' from the node here.
} catch {
debugPrint("Error finding xpath path.")
break
}
}