(solved) reading an xml from a zip

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ericaus
Posts: 14
Joined: Sat Sep 19, 2009 10:53 am
Location: Australia

(solved) reading an xml from a zip

Post by ericaus »

Hello, I'm working on a little game project and I created a function that gets a text string from an xml.

Code: Select all

stringw gameMain::getString(int id)
{

  // Note: This function must be called after initializing
  //          IrrlichtDevice *g_device or else an
  //          'access violation' error will occur.

  stringw text;

  g_device->getFileSystem()->addZipFileArchive("data.zip");

  IrrXMLReader* xml = createIrrXMLReader("data.zip/language/english.xml");

  if (xml == 0)
    return L"Error";

  while (xml->read())
  {
    switch (xml->getNodeType())
    {
    case EXN_TEXT:
      if (strcmp("string", xml->getNodeName()) &&
          xml->getAttributeValueAsInt("id") == id)
      {
          if (xml->getNodeData())
            text = xml->getNodeData();
          else
            text = L"Empty String";
      }
      break;
    }
				
  }

  delete xml;

  return text;
}
This function I have made for my project works if I do not try to read the xml from a zip archive, but when I do it just doesn't seem to work it just ends up calling the xml == 0 IF statement that I have in that function.

So is there any way to get this working? :?
Last edited by ericaus on Wed Oct 07, 2009 7:54 am, edited 2 times in total.
Brainsaw
Posts: 1183
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Did you add the archive to the filesystem with the "addZipFileArchive" method? If so check the parameters, I got some headache from that.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
ericaus
Posts: 14
Joined: Sat Sep 19, 2009 10:53 am
Location: Australia

Post by ericaus »

Brainsaw wrote:Did you add the archive to the filesystem with the "addZipFileArchive" method? If so check the parameters, I got some headache from that.
yeah, I placed addZipFileArchive before calling IrrXMLReader* xml although the xml doesn't want to load from the archive file.
Strangely I can get other things like loadGUI and getFont, and getTexture to load from the zip archive.

edit::
Oh, I think I might of figured it out, lol. Instead of doing,

Code: Select all

IrrXMLReader* xml = createIrrXMLReader("data.zip/language/english.xml");
I tried,

Code: Select all

IXMLReaderUTF8* xml = g_device->getFileSystem()->createXMLReaderUTF8("data.zip/language/english.xml");
Post Reply