Results 1 to 6 of 6
  1. #1
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Exclamation XML read/write in Java

    Hello,
    I am a student at Computer Science, and for an exam that i have this week, i have to make two *.java files, one to read and the other one to write in an XML file.
    The XML should be like this:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <conn_data>
    <adress>localhost</adress>
    <port>1521</port>
    <SID>xe</SID>
    <username>RoCourier_LICENTA</username>
    <password>roco</password>
    </conn_data>

    Please, if someone know to help me.
    Thank you!
    Bogdan - Romania

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Yeah, it's possible with Java. But you must show your effort first of all.

    As a hint, you want to use javax.xml.parsers and javax.xml.xpath and dom too. Read more about those on the Java Doc.

  3. #3
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default Re

    yes, i agree 100%, that`s how i do usualy.
    but i have exams all week and i realy don`t have the time to search and read and stuff... :(:(:(:(:(:(

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Okay, this is how you can locate the XML file.

    Java Code:
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                
                Document doc = docBuilder.parse (new File(file_path));

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by bogdy.laurentiu View Post
    yes, i agree 100%, that`s how i do usualy.
    but i have exams all week and i realy don`t have the time to search and read and stuff... :(:(:(:(:(:(
    Sorry, but this is not our problem and does not change our recommendations as no one's going to do this for you; rather we encourage you to read the lessons on how to work with XML and create your code. Once you have your code created, if you run into problems, please come on back with your code and your questions and we'll be more than happy to help if we can.

    Much luck.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by Fubarable View Post
    Sorry, but this is not our problem and does not change our recommendations as no one's going to do this for you; rather we encourage you to read the lessons on how to work with XML and create your code. Once you have your code created, if you run into problems, please come on back with your code and your questions and we'll be more than happy to help if we can.
    I've just give the way to start on. But as you know that's the only thing I'm doing on this thread. Because if you want to learn something, why you wait until last minute. That's what I believe.

Similar Threads

  1. How to read/write txt in Java
    By megalomitis in forum New To Java
    Replies: 2
    Last Post: 11-13-2009, 10:09 AM
  2. Replies: 1
    Last Post: 07-25-2009, 05:53 PM
  3. How to read first 9 bytes and write in...?
    By aRTx in forum New To Java
    Replies: 8
    Last Post: 03-26-2009, 02:54 PM
  4. Executable java to read and write to a txt file
    By njoymirror in forum New To Java
    Replies: 2
    Last Post: 03-21-2009, 01:19 AM
  5. How Read and Write XMl files using Java
    By tjs in forum SWT / JFace
    Replies: 0
    Last Post: 02-23-2009, 12:19 PM

Posting Permissions

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