Welcome! Log In Create A New Profile

Advanced

XML help

Posted by g_man 
XML help
August 19, 2009 07:20AM
Okay, so when i take this code out my program works fine, it shows what it is supposed to, but when the code is added in, it just shows black. When i hit the 1&2 buttons on the controller they flash, but i don't see why it doesn't work. I haven't worked with XML files ever before and i follower the tutorial at codemii.com.

here is the code that doesn't work
/* First We have to see if the app has an meta.xml.
 This code is the same as for getting boot.dol*/
for(i = 3;i<=dircounter;i++){
	if(applist.getDol() == true){//If the app has a dol
		dp = opendir(applist.getDir());
		while ((ep = readdir(dp))){
			//If the folder has a meta.xml
			if (strcmp(strlower(ep->d_name), "meta.xml") == 0 ){
			/*NOTE:
			strlower, or string lower is needed because
			strcmp is case sensitive, so BOOT.DOL wouldn't
			work*/
				applist.setXml(true); //Set that the app has a dol
				applist.setXmlDir(strcat(applist.getDir(),"/meta.xml")); // Set the directory
			}
		}
	}
	closedir(dp);
}	
/*Now we get the Xml Data*/
for(i = 3;i<=dircounter;i++){
	fileptr = fopen(applist.getXmlDir(),"rb");
	if (fileptr == NULL){
		fclose(fileptr);
	} else {
		//Make sure that the file has data
		fseek(fileptr,0,SEEK_END);
		long setting_size= ftell(fileptr);
		rewind(fileptr);
		
		if(setting_size > 0) {//If there is data
		
			tree = mxmlLoadFile(NULL, fileptr, MXML_NO_CALLBACK);
			fclose(fileptr);
		
			data = mxmlFindElement(tree, tree, "app",NULL,NULL,MXML_DESCEND);
		
			if (mxmlElementGetAttr(data,"name")){//If there is a name
				applist.setName((char*)mxmlElementGetAttr(data,"name"));
			}
			if (mxmlElementGetAttr(data,"coder")){//If there is a coder
				applist.setCoder((char*)mxmlElementGetAttr(data,"coder"));
			}	
			//Will add rest later
		}
	}
}	
When I add the the first half only (untill the /*Now we get the Xml Data*/) It shows the correct background, but no pictures show, but i can tell that the space for them is set (because of a bug it frezees when i click on a picture).
Re: XML help
August 19, 2009 09:05AM
			tree = mxmlLoadFile(NULL, fileptr, MXML_NO_CALLBACK);
			fclose(fileptr);

You are closing the file pointer, I guess (not sure) mxml parses xml in a streamed fashion, so that might be the bug.
Re: XML help
August 20, 2009 06:14AM
That didn't seem to do anything. My other idea is that it is taking really long for the wii to go through the for loop, but i really don't think that's the problem.
Re: XML help
August 20, 2009 09:02AM
Well then,
Can't see any problem with your code actually, checked where I used mxml and indeed whole xml is buffered into memory.

Best way to diagnose the problem is having a means of debugging...
If you have wifi I suggest sysdaemon port of Tekwarrior... you can see it's usage here : [code.google.com]



Edited 1 time(s). Last edit at 08/20/2009 09:02AM by I.R.on.
Re: XML help
August 20, 2009 04:21PM
Ok, I'll try that, I've never debugged something before :( but it can't be that hard.
As soon as i get this fixed i have this problem and one on deleting files with data still in them and i should be good with my program. :)

EDIT:OK, I'm having a lot of trouble compileing the patched version of libogc. The tcpipwifi.c file doesn't compile in the makefile, and so the make file tells me that i don't have all the .o to compile the library. So, i try to compile the file by hand and it gives me tons of errors that make no sense.
Can somebody make me a compiled version of libogc with this patch please?



Edited 3 time(s). Last edit at 08/23/2009 06:51PM by g_man.
Re: XML help
August 29, 2009 05:57AM
Anybody?
Re: XML help
August 29, 2009 09:59AM
For simple debugging, you don't need to patch the ogc...
You can for example use syslogd, here : [forum.wiibrew.org]
Re: XML help
August 29, 2009 04:46PM
Ok i'll try that, but i tryed patching it and everything worked fine so now i just have to learn to use gdb.
Re: XML help
September 02, 2009 11:48PM
The XML code looks pretty good at a quick glance.

I've done similar things with the mxml lib without issue. Download and take a look at [www.dpembo.ukfsn.org] where I use the mxml lib to load and parse an XML file containing skin definitions. You'll find it in the SkinController class.

I suspect there is something more unusual going on and it probably isn't an issue with the XML code itself.

I've had the screen black out when I've tried to printf before it's gone through the init code in the main, and i've also seen it go black using GRRLib for reasons I couldn't really explain, this again may have been related to printf statements - never checked that far though as I just rolled back to the previous version that worked in CVS!

Hope that helps!

I'm seriously thinking about purchasing a Gecko USB thingy, though my PC is quite a distance from the wii, but the pain of copying to a laptop to debug is probably less than sticking loads of sleeps/printfs/exits when things go wrong. I might take a look at the syslogd thing - thanks :)



Edited 1 time(s). Last edit at 09/02/2009 11:49PM by pembo.
Re: XML help
September 03, 2009 07:04PM
If you know how to use GDB you can use this. If you need help patching or compiling libogc, i can probably send you one i compiled, that way you don't need to buy a USB Gekko.
Sorry, only registered users may post in this forum.

Click here to login