. . . . . .
I want each of the p tag inside the data, are placed inside a dictionary type. Then type the dictionary into an array of instances go, I use kissxml. Posted the following statement.
- (Void) kissXMLForString1: (NSString *) xmlString
{
DDXMLDocument * xmlDoc = [[DDXMLDocument alloc] initWithXMLString: xmlString options: 0 error: nil];
NSArray * items = nil ;/ / temporary storage of data
NSDictionary * Dict = nil;
items = [xmlDoc nodesForXPath: KP error: nil];
NSLog (@ "% @", KP);
NSLog (@ "% @", items);
for (DDXMLElement * item in items) {
Dict = [item attributesAsDictionary];
NSLog (@ "% @", Dict);
[Allarray addObject: Dict];
/ / NSString * sss = [[item attributeForName: @ "pn"] stringValue];
/ / NSLog (@ "% @", sss);
}
}
Statement is very simple, but there was no data items, heroes seek help, how can I parse the data, and put allarray inside! ! !
Thank you!
Reply:
kissxml. . Not used ah. . Are using this right. .
public List
String xml = inputToString (is);
SAXParserFactory saxPraseFactory = SAXParserFactory.newInstance ();
infos = new ArrayList
try {
XMLReader xmlReader = saxPraseFactory.newSAXParser (). GetXMLReader ();
UserNumContentHandler userContentHandler = new UserNumContentHandler (
infos);
xmlReader.setContentHandler (userContentHandler);
xmlReader.parse (new InputSource (new StringReader (xml)));
/ / For (Iterator iterator = infos.iterator (); iterator.hasNext () ;) {
/ / UserManager um = (UserManager) iterator.next ();
/ / Result [index + +] = um.getName ();
/ /}
} Catch (Exception e) {
e.printStackTrace ();
}
Reply:
TouchXML I use this, there are many online introduction, the landlord try this
Reply:
items = [xmlDoc nodesForXPath: KP error: nil];
The KP is what ah?
I feel this KP should be replaced by @ "P" or @ "/ / P" try it, so as to get to the
number, that is, the count your items
No comments:
Post a Comment