sorry can't get it to work.
I have an xml string:
<data>
<project>123 first</project>
<project>234 second</project>
<project>345 third</project>
</data>
I now use a function where I look for project in the string and then find the correct value and append it to my StringArray
var StringArray: [String] = []
this works as expected but now the project is growing to over 2000 records in the xml file and it takes more than 15 seconds to get the values in the StringArray.
public func getArrayFromXMLString(xml: String, node: String) -> [String] {
var xml2: String = xml
var ArrayName = [String]()
while xml2.range(of: "<" + node + ">") != nil {
let i1 : Int = xml2.indexOf("<" + node + ">")!
xml2 = xml2.right(xml2.length - i1)
let i2 : Int = xml2.indexOf(">")!
xml2 = xml2.right(xml2.length - i2 - 1)
let i3 : Int = xml2.indexOf("<")!
ArrayName.append(xml2.left(i3))
}
return ArrayName
}
(some functions are used for indexof, left and right)
I found a lot of examples with XMLParser but none with only the one property. I have obviously never used XMLParser.
Can someone guide me in the correct way please?