need example please. writing to XML file

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
Wolf Dreamer
Posts: 121
Joined: Tue Feb 10, 2004 6:39 am
Location: the land of chaotic dreams
Contact:

need example please. writing to XML file

Post by Wolf Dreamer »

I'm not sure why, but I seem to be having a lot of difficulty getting this to work.

Will someone please post some code I can use to write to an XML file.

I get nothing but errors when I try to copy and paste things from http://irrlicht.sourceforge.net/docu/cl ... riter.html
The last sane human being in a world gone mad

http://s8.invisionfree.com/Game_Maker_f ... hp?act=idx
Wolf Dreamer
Posts: 121
Joined: Tue Feb 10, 2004 6:39 am
Location: the land of chaotic dreams
Contact:

I found a misprint in the API

Post by Wolf Dreamer »

http://irrlicht.sourceforge.net/docu/cl ... eader.html
The code for parsing this file would look like this:

io::IXMLReader* xml = device->getFileSystem()->createXMLReader("config.xml");
Device should be capitalized otherwise it causes an error.

Getting the reader to work isn't a problem, since there is an example in the Meshviewer code, as well as on the API list. I'm still having trouble with the writer though.

I just got this error:
h:\irrlicht-0.6\include\IXMLWriter.h(19) : see declaration of 'irr::io::IXMLWriter'
I put in include IXMLWriter.h in the meshviewer code, thinking perhaps that was the problem. Nope. It doesn't like that either.
The last sane human being in a world gone mad

http://s8.invisionfree.com/Game_Maker_f ... hp?act=idx
Wolf Dreamer
Posts: 121
Joined: Tue Feb 10, 2004 6:39 am
Location: the land of chaotic dreams
Contact:

Post by Wolf Dreamer »

h:\irrlicht-0.6\examples\9.Meshviewer\main.cpp(344) : error C2761: 'void irr::io::IXMLWriter::writeXMLHeader(void)' : member function redeclaration not allowed
Someone please tell me what I'm doing wrong. I got everything else working fine I think. No matter what I put in the () it doesn't work.

Eagerly awaiting a reply. I'm sure someone has got the XML writer to work by now... hopefully.
The last sane human being in a world gone mad

http://s8.invisionfree.com/Game_Maker_f ... hp?act=idx
kakTuZ
Posts: 12
Joined: Sun Mar 14, 2004 7:28 pm
Location: Hannover (Germany)

Post by kakTuZ »

Hi,
the xml-reader is used in the Mesh-viewer example. And in the documentation is the same example.
Be sure you save your xml-file as unicode otherwise he can't read the EOF and repeats infinit the last code (thats the mistake i did :? )
And if your problems still exist youre welcome to post a bit more of your code

greetings
Maxi
Wolf Dreamer
Posts: 121
Joined: Tue Feb 10, 2004 6:39 am
Location: the land of chaotic dreams
Contact:

Post by Wolf Dreamer »

I have no problems with the READER. I just need to know how to use the WRITER.

I just posted the spelling error for the reader in my post asking about the writer.

Anyway, can you get it to write to a new XML file? If so, please post some code.
The last sane human being in a world gone mad

http://s8.invisionfree.com/Game_Maker_f ... hp?act=idx
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Here's some code:

Code: Select all

io::IXMLWriter* xml = Device->getFileSystem()->createXMLWriter("file.xml");
	
xml->writeXMLHeader();
xml->writeLineBreak();

xml->writeComment(L"This is a Comment");
xml->writeLineBreak();

xml->writeElement(L"Element1", false);
xml->writeText(L"Text");
xml->writeClosingTag(L"Element1");
xml->writeLineBreak();

xml->writeElement(L"Element2", true, L"Attr1", L"Val1");
It creates a (unicode) file with the following content:

Code: Select all

<?xml version="1.0"?>

<!--This is a Comment-->
<Element1>Text</Element1>
<Element2 Attr1="Val1" />
Easy? :)

regards,
jox
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

And it isn't a spelling mistake for device to be spelt without a capitol, it's a pointer. The pointer could be myGameDevice and it would do the same thing.
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

exactly!
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

One little addition to my code example.

Don't forget to add the following at the end. (Because you're using a 'create' function (see docs for grab()/drop())).:

Code: Select all

xml->drop();
Last edited by jox on Wed May 19, 2004 12:07 am, edited 1 time in total.
Wolf Dreamer
Posts: 121
Joined: Tue Feb 10, 2004 6:39 am
Location: the land of chaotic dreams
Contact:

Post by Wolf Dreamer »

13 minutes after my last post someone actually replied. Ack! Why didn't I notice that before?

Anyway, thanks. That works.

Anxiety willing, one of these days I'll actually get something finished.
The last sane human being in a world gone mad

http://s8.invisionfree.com/Game_Maker_f ... hp?act=idx
Post Reply