reading information from XML file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: reading information from XML file

  1. #1
    Join Date
    Jan 2005
    Posts
    7

    reading information from XML file

    I am currently writing an address book type program. I am wanting to use an XML file to read and write data to. I have gone through some tutorials on DOM and JDOM. If i have an entry set up like below

    <AddressBook>
    <entry>
    <fName>bob</fName>
    <lName>howser</LName>
    </entry>
    ...
    ...
    ...
    </AddressBook>
    Where the ... are more entry's
    in my program i want to display one entry and have navigation buttons the user can press to move to the next entry. Would it be possibe to navigate the XML file in this way. I don't have any actual code yet for my program, I have done some tutorials on sun to get a basic understanding of this. Any help is greatly appreciated.

  2. #2
    Join Date
    Nov 2004
    Location
    Minnesota
    Posts
    99
    Sure.

    slap on your buttons for navigations, and JTextFields(or whatever) for displaying content

    At form load time, populate a DOM tree from the XML using a DOMParser, take the resulting Document and set it as a member of your component(JFrame or whatever), get some kind of iterator from the Document, and initialize your fields from the first record (if there is one).

    When next or previous buttons are clicked, you just use the iterator to move forward or backward over the document, repopulating the form's fields with the current record (if there is one).

    Actual implementation is up to you, of course.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center