You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if let path = bodyNode?.xpath("//div[@class='box']") {
for node in path {
println("fancy node \(node.tagName)")
println(node.xpath(".//h2")?.count) //=> Change "//h2" to ".//h2"
}
}
When you change the sample HTML to have 2 box classes,
...... " <div class='box'>" + " <span class='dat'>" + " <strong content='2014-12-31'>2014/12/31</strong>" + " </span>" + " <h2>Hoge</h2>" + " </div>" + " <div class='box'>" + " <span class='dat'>" + " <strong content='2014-12-31'>2014/12/31</strong>" + " </span>" + " <h2>SecondHoge</h2>" + " </div>" ......
and then when you run
if let path = bodyNode?.xpath("//div[@class='box']") { for node in path { println("fancy node \(node.tagName)") println(node.xpath("//h2")?.count) } }
it returns
fancy node div
Optional(2)
fancy node div
Optional(2)
as answer, which I think is wrong and should return 1 & 1.
The text was updated successfully, but these errors were encountered: