0

I made an XML with php and MYSQL, but when i try to parse it into iphone dont seems to work, since in the internet adress it look correctly...Here the XML:

<feed xmlns="http://74.53.32.202/~ltashiro/public/Servidor/">
<title>ServidorBaladasRSS</title>
<subtitle>Agenda</subtitle>
<Prog Id="1" Nome="Club" Desc="" Data="2011-11-01 00:00:00" Dia="2"/>
<Prog Id="1" Nome="Club" Desc="" Data="2011-11-01 00:00:00" Dia="3"/>
<Prog Id="1" Nome="Club" Desc="" Data="2011-11-01 00:00:00" Dia="4"/>
<Prog Id="2" Nome="Test" Desc="" Data="2011-11-01 00:00:00" Dia="1"/>
<Prog Id="2" Nome="Test" Desc="" Data="2011-11-01 00:00:00" Dia="2"/>
<Prog Id="2" Nome="Test" Desc="" Data="2011-11-01 00:00:00" Dia="3"/>
<Prog Id="2" Nome="Test" Desc="" Data="2011-11-01 00:00:00" Dia="4"/>
</feed>

The Objective-C:

-(void) parser:(NSXMLParser *) parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) nameSpaceURI qualifiedName:(NSString *) qName attributes:(NSDictionary *) attributeDict
{
      NSLog(@"%@",elementName);
}

I need the XML to be in that format,when i Log the elementName it logs only the feed,title and subtitle, the rest of the XML looks like dont exists...

something wrong with the XML formatting?

1
  • To eliminate a couple of variables, try running your code with text instead of attributes for Prog. Also, run it with the tag name "prog", i.e. lowercase. Commented Nov 1, 2011 at 19:22

1 Answer 1

2

I just put this code into viewDidLoad of a ViewController and ran it and it produced output including your Prog elements (output shown below the code) so double check your data/encoding etc.:

- (void)viewDidLoad {
    NSString *testXml = @"<feed xmlns=\"http://74.53.32.202/~ltashiro/public/Servidor/\">\
    <title>ServidorBaladasRSS</title>\
    <subtitle>Agenda</subtitle>\
    <Prog Id=\"1\" Nome=\"Club\" Desc=\"\" Data=\"2011-11-01 00:00:00\" Dia=\"2\"/>\
    <Prog Id=\"1\" Nome=\"Club\" Desc=\"\" Data=\"2011-11-01 00:00:00\" Dia=\"3\"/>\
    <Prog Id=\"1\" Nome=\"Club\" Desc=\"\" Data=\"2011-11-01 00:00:00\" Dia=\"4\"/>\
    <Prog Id=\"2\" Nome=\"Test\" Desc=\"\" Data=\"2011-11-01 00:00:00\" Dia=\"1\"/>\
    <Prog Id=\"2\" Nome=\"Test\" Desc=\"\" Data=\"2011-11-01 00:00:00\" Dia=\"2\"/>\
    <Prog Id=\"2\" Nome=\"Test\" Desc=\"\" Data=\"2011-11-01 00:00:00\" Dia=\"3\"/>\
    <Prog Id=\"2\" Nome=\"Test\" Desc=\"\" Data=\"2011-11-01 00:00:00\" Dia=\"4\"/>\
    </feed>";

    NSData *ourData =   [testXml dataUsingEncoding:NSUTF8StringEncoding]; 

    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:ourData];
    [parser setDelegate:self];
    [parser parse];
}

-(void) parser:(NSXMLParser *) parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) nameSpaceURI qualifiedName:(NSString *) qName attributes:(NSDictionary *) attributeDict
{
      NSLog(@"%@",elementName);
}

This produced the following output:

[Session started at 2011-11-02 15:54:01 +1100.]
2011-11-02 15:54:04.965 TESTXML[1517:207] feed
2011-11-02 15:54:04.966 TESTXML[1517:207] title
2011-11-02 15:54:04.967 TESTXML[1517:207] subtitle
2011-11-02 15:54:04.967 TESTXML[1517:207] Prog
2011-11-02 15:54:04.968 TESTXML[1517:207] Prog
2011-11-02 15:54:04.968 TESTXML[1517:207] Prog
2011-11-02 15:54:04.969 TESTXML[1517:207] Prog
2011-11-02 15:54:04.969 TESTXML[1517:207] Prog
2011-11-02 15:54:04.970 TESTXML[1517:207] Prog
2011-11-02 15:54:04.970 TESTXML[1517:207] Prog
Sign up to request clarification or add additional context in comments.

1 Comment

After read and read again the code i think there was a problem with the synthax on the objective-C

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.