I'm already known with TBXML on how to parse it in my Xcode project. But I'm stuck on an XML Structure I don't know well.
This is the XML Structure:
<CurDate Dates="27.07.2012" Date="07/27/2012">
<Currency Kod="USD" CurrencyCode="USD">
<Unit>1</Unit>
<Name>AMERICA</Name>
<CurrencyName>US DOLLAR</CurrencyName>
<ForexBuying>1.81</ForexBuying>
<ForexSelling>1.8187</ForexSelling>
</Currency>
</CurDate>
I want help on this XML Structure. My code looks like:
TBXMLElement *elementName = [TBXML childElementNamed:@"Currency" parentElement:element];
TBXMLElement *altinTemp = [TBXML childElementNamed:@"CurrencyName" parentElement:elementName];
This is my way to get the CurrencyName of my XML, but I get an error on this. See code:
+ (TBXMLElement*) childElementNamed:(NSString*)aName parentElement:(TBXMLElement*)aParentXMLElement{
TBXMLElement * xmlElement = aParentXMLElement->firstChild;
const char * name = [aName cStringUsingEncoding:NSUTF8StringEncoding];
while (xmlElement) {
if (strlen(xmlElement->name) == strlen(name) && memcmp(xmlElement->name,name,strlen(name)) == 0) {
return xmlElement;
}
xmlElement = xmlElement->nextSibling;
}
return nil;
}
This is were I get an error. The error is "Thread 1: EXC_BAD_ACCESS (code=2, address=0x10)
Any reply will good for me! Thanks.