This may be a basic question but, I have a game that is in XML format. I want the speakers and lines to be desired. I want to add it to a single dictionary and add it to an array. Here's the format
& lt; Speech & gt; & Lt; Speaker & gt; Statement & lt; / Speaker & gt; & Lt; LINE & gt; Two families, both equally respected, & lt; / LINE & gt; & Lt; LINE & gt; In fair Verona, where we keep our view, So I want to get the narrator as the speaker and the line and add it to the dictionary after that I want to add the dictionary to the array and Then I want to clear the dictionary. How can I do this?
thanks
I am infronting one of your original tags in your question I am in that you are doing this purpose. I will assume that you want to use it.
So, suppose you have (a) a subliminal array of speeches ; (B) a temporary dictionary for the current speech ; (C) An unstable array of lines for each speech; And (D) a temporary string, value , which will capture the characters between the beginning of the name of an element and the end of the name of that element. Then, you apply the methods for example, as you are parsing, in you, if you get the name of a speech element, then you make a dictionary:
if ([elementName isEqualToString: @ "Speech"]) {speech = [[NSMUTABLEDACACOLLO] INIT]; Rows = [[NSMUTABELARROR] INIT]; } Other {value = [[NSMUTABLE string alok] init]; } As you face characters in, you add them to value : [value appendString : String]; And, if you have a speaker, set it up, if you get a line, add it, and if you close speech If you get the tag, then go ahead and add speeches in your array (with your SPEAKER and LINES ): [ElementName isEqualToString: @ "SPEAKER" [] [[Value for the speech set object: @ "speaker"];} and if ([elementNameEqualToString: @ "LINE"]) {[lines addObject: value];} and if ([ElementNameEqualToString: @ "Speech"]] [[Speech Set Object Q: For lines: @ "line"]; [to add speeches: speech]; speech = zero; lines = zero;} value = zero; More information , Or Google "NSXMLParser Tutorial."
No comments:
Post a Comment