Reading an xml file into java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Reading an xml file into java

  1. #1
    Join Date
    Dec 2005
    Posts
    2

    Reading an xml file into java

    I am new to Java and XML. I am trying to figure out how to read in this XML file and use the elements to determine certain conditions. I will paste my XML file below. In my application, I am going to ask the user to enter a username, password and filename. I want to say in my Java code:
    if filename = (file name user entered) and user is (username user entered)
    print “Access allowed
    else
    print “Access denied”

    As you can see, the XML file will contain the roles and the usernames associated with those roles. I know how to write the Java code for everything else except reading in the XML file. Can someone give me some help on how to get that going?
    Code:
    <?xml version="1.0"?>
    <security>
    <role>
       <title>Admin</title>
       <name>Kim</name> 
    </role>
    
    <role>
       <title>HR</title>
       <name>Joyce</name> 
    </role>
    
    <role>
       <title>Accting</title>
       <name>Michael</name> 
    </role>
    
    <role>
       <title>Manager</title>
       <name>John</name> 
    </role>
    
    </security>

  2. #2
    Join Date
    Dec 2005
    Posts
    48
    You can download a Xerces2 from apache.with which you do read xml file very easily.
    Jdom is also a good choice.

    http://www.wisesoft.biz/
    http://www.jvsoft.org/

Similar Threads

  1. Reading from XML file
    By alfonso101 in forum Java
    Replies: 0
    Last Post: 11-26-2005, 11:17 AM
  2. updating xml file from VB6
    By smithg22 in forum VB Classic
    Replies: 9
    Last Post: 04-12-2005, 06:23 PM
  3. Replies: 2
    Last Post: 11-14-2001, 12:49 PM
  4. reading multiple text files
    By simon in forum XML
    Replies: 6
    Last Post: 07-27-2001, 12:58 PM
  5. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 10:53 AM

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