Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: I need help to figure out what went wrong with my xml-writing.

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question I need help to figure out what went wrong with my xml-writing.

    *Solved by myself. The saved files just required some whitespace and/or indents to work.

    Hi. I am currently experimenting with a maze-game, and I am working on an editor for it.
    At this time, I am working on a save/load function that use xml.

    I manually created a test-document while writing the load-function, and it went well. The end result was exactly as i described in the manually written xml document.
    testmaze.jpg

    However, when working on the save-function, I set it to first load my manually written test, then save the data (in other words, a copy).
    When loading the copy, things didn't go as planned.
    testsavemaze.jpg

    For some reason, all the walls are up, when only the ones on the outside and around the center is supposed to.

    The .xml files are in the attached .zip.
    Also in the .zip is the source-codes for the save and load classes.
    Attached Files Attached Files


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: I need help to figure out what went wrong with my xml-writing.

    You're going to want to post an SSCCE that we can just copy and paste to experiment with. The easier it is for people to help you, the more likely it is you'll get help!
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help to figure out what went wrong with my xml-writing.

    Hum... I see.
    SSCCE seems a bit complicated, but I will see what I can do to upload such a version of my project.
    If I understand that correctly, it would mean I will have to upload all of the source-files related to saving and loading...

    Well, I wont do it tonight, a bit too late.
    If I don't get a helpful reply by morning, I will start working on an SSCCE.

  4. #4
    Junior Member
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help to figure out what went wrong with my xml-writing.

    I am quite sorry, but I forgot about creating that SSCCE version.
    I researched areound meself, and figured out that my xml documents simply needs whitespace to work, so all I needed, was to add one line of code in the save-class:

    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    This makes me wonder why that property is off by default, but at least I got it working.

    Now my code works as expected, the bug is gone, and this problem is solved.

Similar Threads

  1. Cannot figure out why this is wrong............
    By gabgab96 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 27th, 2013, 06:58 AM
  2. Can't figure out why this is wrong
    By gabgab96 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 26th, 2013, 10:25 PM
  3. [SOLVED] Would Really Appreciate Some Help!! Trouble Writing XML File From GUI :(
    By Raggazz4 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 11th, 2012, 07:37 AM
  4. Can't figure out what's wrong
    By xdx in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 10th, 2012, 09:48 AM
  5. i cannot figure out what's wrong
    By biyuss in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 17th, 2011, 10:22 PM

Tags for this Thread