Results 1 to 3 of 3

Thread: Writing to XML file

  1. #1

    Default Writing to XML file

    Hi there, I'm rather new to this so please be patient.

    I wish to use an XML file to save data in. I'm a bit confused as to how everything works though. Loading resources such as sprites is fine, since I can see how it works in the examples.

    However I couldn't find an example on how to save. So I've been trying by playing around:

    Code:
    CL_File testfile("data.xml", CL_File::create_always);
    CL_DomDocument doc(testfile);
    CL_DomElement elem(doc,"Element","Namespace");
    elem.set_attribute("testing","5");
    doc.save(testfile,true);
    testfile.close();
    However this just creates the file without saving anything to it. I know I'm doing something simple. How can I fix it?

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    The correct syntax is:

    Code:
    CL_File testfile("data.xml", CL_File::create_always);
    CL_DomDocument doc(testfile);
    CL_DomElement elem = doc.create_element("Element");
    elem.set_attribute("testing","5");
    doc.append_child(elem);
    doc.save(testfile,true);
    testfile.close();

  3. #3

    Default

    Excellent!

    Thank you very much Magnus Norddahl.

Similar Threads

  1. Problems with resource file
    By LonelyStar in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 04-26-2008, 12:25 PM
  2. write to XML file
    By DavinciZhe in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 01-20-2008, 12:21 PM
  3. jjohn's welcome2.swf file
    By File Sponge in forum Funeral Quest
    Replies: 6
    Last Post: 11-13-2006, 07:54 AM
  4. Clean dink.ini file!
    By Davidi in forum Dink Smallwood HD
    Replies: 0
    Last Post: 07-09-2004, 10:24 AM
  5. Clean dink.ini file!
    By Davidi in forum Dink Smallwood HD
    Replies: 0
    Last Post: 07-09-2004, 10:23 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •