Позвольте мне прояснить вашу проблему на простом примере, который я получил от форума TBXML
Если вы хотите разобрать XML что-то вроде,
<xml>
<alert id="b19260fa7f00000100258097dcd87ab7">
<title>MU-Lancaster Now Open</title>
<startdate>1304353800</startdate>
<enddate>1304362800</enddate>
<type>Emergency</type>
<message>
<p>MU-Lancaster, at 42 N. Prince St., in Lancaster, is now open.  It had been closed this morning due to the evacuation of downtown Lancaster.</p>
</message>
</alert>
Чем вам нужно написать код для разбора, так это:
- (void)parseMuAlertXML{
TBXML *tbxml;
TBXMLElement *rootXMLElement;
TBXMLElement *node_alert;
TBXMLElement *node_message;
TBXMLElement *node_traverse;
time_t unixTime = (time_t) [[NSDate date] timeIntervalSince1970];
NSURL *url = [NSURL URLWithString:@"http://www.millersville.edu/alert/alert.xml"];
tbxml = [TBXML tbxmlWithURL:url];
rootXMLElement = tbxml.rootXMLElement;
если (rootXMLElement)
{
node_alert = [TBXML childElementNamed: @ "alert" parentElement: rootXMLElement];
if(node_alert)
{
node_traverse = [TBXML childElementNamed:@"startdate" parentElement:node_alert];
NSInteger startString = [[TBXML textForElement:node_traverse] intValue];
time_t startTime = startString;
node_traverse = [TBXML childElementNamed:@"enddate" parentElement:node_alert];
NSInteger endString = [[TBXML textForElement:node_traverse] intValue];
time_t endTime = endString;
node_traverse = [TBXML childElementNamed:@"type" parentElement:node_alert];
alertType = [[TBXML textForElement:node_traverse] retain];
node_message = [TBXML childElementNamed:@"message" parentElement:node_alert];
if(node_message)
{
node_traverse = [TBXML childElementNamed:@"p" parentElement:node_message];
alertMessage = [TBXML textForElement:node_traverse];
alertMessage = [alertMessage stringByReplacingOccurrencesOfString:@" " withString:@" "];
}
if((unixTime >= startTime) && (unixTime <= endTime))
{
[alertButton setHidden:NO];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
} else {
[alertButton setHidden:YES];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
}
}
}
}
также ваш xml не является действительным xml,
Я думаю, что ваш XML будет,
<step id="123"> this string is not parsed<draw_at x="1964"/><partials><partial sd="23"><line>ANOTHER TEXT 1</line><line>ANOTHER TEXT</line></partial></partials></step>