I am parsing a website, for an inorganic compound, and need to get it's chemical formula.
let data = NSData(contentsOf: URL(string: "https://en.wikipedia.org/wiki/Gold(III)_bromide")!)
let doc = TFHpple(htmlData: data as! Data)
if let elements = doc?.search(withXPathQuery: "//*[@class='selflink']/text()") as? [TFHppleElement] {
for element in elements {
print("------")
print(element.content)
}
}
It prints out "AuBr" But I need it to print the whole formula out which is "AuBr3"
This is the html code I'm getting the formula from:
How can I make it print out the whole formula with the 3 at the end?