Here's my code that creates the parser:
Here's the log output I'm getting:
Here's the contents of my XML file (which is also attached to my post - I added the .txt to the end just so the forums would let me upload it. The extension is just .xml in my project.)
Any ideas for why it's able to read the first attribute just fine but then fails to read the others?
Edit: T.T - Solved already, again. I removed all the closing star tags and it worked fine... now the question is, why? It seems to me that my XML file was properly formatted before, and now it is not?
Edit 2X: I added <main> before my first <star [...]>, put the </star>'s back, and added </main> after the last </star>... and now it continues to work. So, I guess this is resolved, seconds after I made it and before anyone responded.
Still, I guess if anyone googles the title in the future, they'll see the solution.
Code:
- (TSManager*)initWithRootNode:(Ogre::SceneNode*)node level:(NSString*)theLevelID
{
if (self = [super init])
{
rootNode[2] = node;
levelID = theLevelID;
[b]NSString* firstFilePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"Contents/Resources/media/levels/%@00.xml", theLevelID]];
[self loadFile:[NSURL fileURLWithPath:firstFilePath]];[/b]
}
return self;
}
- (void)loadFile:(NSURL*)URL
{
NSLog(@"Attempting to load a file: %@", [URL description]);
NSXMLParser* parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
parser.delegate = self;
[parser parse];
//[parser release];
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
NSLog(@"Error occured: %@", [parseError localizedDescription]);
}
- (void)parserDidStartDocument:(NSXMLParser *)parser
{
NSLog(@"Started.");
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
NSLog(@"Finished element.");
}
- (void)parser:(NSXMLParser*)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
NSLog(@"Parser did start element.");
if ([elementName isEqualToString:@"star"])
{
float X = [[attributeDict objectForKey:@"X"] floatValue];
float Y = [[attributeDict objectForKey:@"Y"] floatValue];
float Z = [[attributeDict objectForKey:@"Z"] floatValue];
star[starCount] = [[TSStar alloc] initAtX:X Y:Y Z:Z relativeTo:rootNode[2]];
starCount++;
}
}
Here's the log output I'm getting:
Code:
2012-07-17 19:34:41.542 TwiStar[42854:303] Attempting to load a file: file://localhost/Users/Taylor/Library/Developer/Xcode/DerivedData/TwiStar-avyztnbwsppjwyfneuwcywqgnhib/Build/Products/Debug/TwiStar.app/Contents/Resources/media/levels/A00.xml
2012-07-17 19:34:41.543 TwiStar[42854:303] Started.
2012-07-17 19:34:41.543 TwiStar[42854:303] Parser did start element.
2012-07-17 19:34:41.545 TwiStar[42854:303] Finished element.
2012-07-17 19:34:41.547 TwiStar[42854:303] Error occured: The operation couldnt be completed. (NSXMLParserErrorDomain error 5.)
Here's the contents of my XML file (which is also attached to my post - I added the .txt to the end just so the forums would let me upload it. The extension is just .xml in my project.)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<star X="0" Y="12" Z="-50"> </star>
<star X="6" Y="10.4" Z="-100"> </star>
<star X="10.4" Y="6" Z="-150"> </star>
<star X="12" Y="0" Z="-200"> </star>
<star X="10.4" Y="-6" Z="-250"> </star>
<star X="6" Y="-10.4" Z="-300"> </star>
<star X="0" Y="-12" Z="-350"> </star>
<star X="-6" Y="-10.4" Z="-400"> </star>
<star X="-10.4" Y="-6" Z="-450"> </star>
<star X="-12" Y="0" Z="-500"> </star>
<star X="-10.4" Y="6" Z="-550"> </star>
<star X="-6" Y="10.4" Z="-600"> </star>
<star X="-3" Y="5.2" Z="-650"> </star>
<star X="0" Y="0" Z="-700"> </star>
Any ideas for why it's able to read the first attribute just fine but then fails to read the others?
Edit: T.T - Solved already, again. I removed all the closing star tags and it worked fine... now the question is, why? It seems to me that my XML file was properly formatted before, and now it is not?
Edit 2X: I added <main> before my first <star [...]>, put the </star>'s back, and added </main> after the last </star>... and now it continues to work. So, I guess this is resolved, seconds after I made it and before anyone responded.
Still, I guess if anyone googles the title in the future, they'll see the solution.
Attachments
Last edited: