0

The current project what i m doing is to parse an xml file and load it in table view.if i m to click the first row of the tableview it got to lead me to another table view containg parsed xml data of another file. i ve got an xml file named as categories.xml which is the main file and is linked to three other xml files.with categories.xml as the base file .ive got the urls of the other xml files enclosed in the tag named "url" in categories.xml.if i m to parse the categories.xml using nsxmlparser the parsing works fine and was able to successfully populate the data in table view.but the problem is if i m to parse the tag containing the url .i m able to get the data enclosed in the url tag (which is the url of another xml file)but was not able to parse once again the data ecnlosed in the url tag ...i m getting a null data in in NSURLRequest in ma console...below is the link to the xml file and the code..i even ready to give u any extra code...cud u guys help me out

http://www.1040communications.net/sheeba/stepheni/iphone/categories.xml

below is the code....

http://pastie.org/2283041

kingston
  • 1,553
  • 4
  • 22
  • 42
  • Format your question. Also paste code where you parse categories and get the url. – Praveen S Jul 28 '11 at 05:21
  • it might be simpler to go with the plist format and read it in with NSMutableArray or NSMutableDictionary – Alex Kremer Jul 28 '11 at 05:31
  • @godexsoft:cud u send me an example of how to parse using plist on the above xml link ive given..i d be so greatful... – kingston Jul 28 '11 at 05:34
  • @kingston check this out: http://stackoverflow.com/questions/5354623/how-do-i-load-a-plist-file-from-disk-as-a-nsdictionary-on-ios but bare in mind that you need to use the plist xml format, not your current format. That's the downside of switching to plist. – Alex Kremer Jul 28 '11 at 05:38
  • @godexsoft:i havent tried parsing using plist...is it fine if i give u a plist file loaded in my FTPserver...so dat u cud parse a small segment..thanks in advance.. – kingston Jul 28 '11 at 05:47

1 Answers1

0
// podcast url is an attribute of the element enclosure
    if ([currentElement isEqualToString:@"enclosure"]) {
        [currentPodcastLink appendString:[attributeDict objectForKey:@"url"]];
    }

you are trying to access the url as attribute --- As per my understanding url is a element so you should access with element.

if ([elementName isEqualToString:@"url"]) 
Girish Kolari
  • 2,515
  • 2
  • 24
  • 34
  • i ve modified my previous code...i m not using the currentPodcastLink...i m using dis [item setObject:self.currentLink forKey:@"url"];..it works fine...but the problem i m not able to parse the content in the url once again in de url if u want i cud u de entire zip file of my project – kingston Jul 28 '11 at 06:19
  • Can you post you new code for "- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ " – Girish Kolari Jul 28 '11 at 06:22
  • cud u gimme ur email id..i d giv u my entire zip file – kingston Jul 28 '11 at 06:24
  • I just tested your code .. it store the url value in dictionary just that it have some extra '\n' get appended to the url ... – Girish Kolari Jul 28 '11 at 06:35
  • :its like dis de above xml file contains links to 3 other xml files ..wat i want is to parse the categories.xml show the title in table view.(which works fine)..the url link that is inside the tag needs to be parsed once again coz its an xml and need to be populated in another table view .when the user clicks the first row he got to get a new table view containing the parsed items and is not happening and i m getting a null value NSLog(@"hello:%@",baseURL); but the url is getting parsed successfully .... – kingston Jul 28 '11 at 06:41
  • in your url it is getting extra '\n' at the end just try removing it and test .. it should solve the problem ... you can do some thing like this - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ if ([string isEqualToString:@"\n"]) { return; } .... – Girish Kolari Jul 28 '11 at 06:48
  • @GirishKolari let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/1909/discussion-between-user652878-and-girish-kolari) – kingston Jul 28 '11 at 06:51
  • cud u paste me the url where u r getting the /n...i ve checked my console..i havent got something like dat... – kingston Jul 28 '11 at 06:55
  • @GirishKolari let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/1911/discussion-between-kingston-and-girish-kolari) – kingston Jul 28 '11 at 07:13