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 2 of 2

Thread: How to Convert following XML to ArrayList

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Location
    Pune, India
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to Convert following XML to ArrayList

    Hello Expert,

    I am new on java. I have following xml file structure.
    What I need to do is that
    1) Read this xml file and convert to arraylist.
    2) insert this arrayList into Mysql database.

    Please help out

    XML File is

    <?xml version="1.0"?>
    <root>
    <individualorders>
    <individualorder>
    <patientRole>
    <id>8839</id>
    <addr >
    <streetAddressLine/>
    <city/>
    <state/>
    <postalCode/>
    <country/>
    </addr>
    <telecom />
    <mobilenumber>1234567890</mobilenumber>
    <patient>
    <name>
    <salutation>Mr</salutation>
    <firstname>TFnam tMidName tLastName</firstname>
    <middlename/>
    <family/>
    </name>
    <administrativeGenderCode>Male</administrativeGenderCode>
    <birthTime>-00011130</birthTime>
    <age>
    <years>2014</years>
    <months>07</months>
    <days>1</days>
    </age>
    <birthplace>
    <place>
    <addr>
    <state/>
    <postalCode/>
    <country/>
    </addr>
    </place>
    </birthplace>
    </patient>
    </patientRole>
    <orderinfo>
    <id>9066</id>
    <grossamount>0</grossamount>
    <discountamount>0</discountamount>
    <discountpercentage>0</discountpercentage>
    <reasonfordiscount>NA</reasonfordiscount>
    <netamount>0</netamount>
    <referringdoctor>-</referringdoctor>
    <referringdoctorcontact>-</referringdoctorcontact>
    <ordertype>catalog</ordertype>
    <medicalhistory>-</medicalhistory>
    </orderinfo>
    <tests>
    <test>
    <testcode>4320</testcode>
    <packageid>11729</packageid>
    <testid>4320</testid>
    <testname>Collage - Executive Health Chk Up - Male</testname>
    <sellingprice>0</sellingprice>
    </test>
    Test can be more
    </tests>
    </individualorder>
    </individualorders>
    </root>


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to Convert following XML to ArrayList

    What exactly should the ArrayList contain? Write out the rules you want to follow, then write methods that follow those rules.

    You could also look into XML libraries like jaxb that handle XML conversion for you.
    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!

Similar Threads

  1. convert arraylist to 2D array
    By ishrne in forum Object Oriented Programming
    Replies: 5
    Last Post: April 5th, 2013, 07:57 AM
  2. [SOLVED] How convert sting name as an arrayList name?
    By Purple01 in forum Java Theory & Questions
    Replies: 0
    Last Post: November 27th, 2012, 07:46 AM
  3. convert excel to xml and read the input from xml file
    By rahulruns in forum Object Oriented Programming
    Replies: 5
    Last Post: April 3rd, 2012, 11:13 AM
  4. Convert Text files to XML
    By HelloAll in forum Java Theory & Questions
    Replies: 1
    Last Post: February 2nd, 2011, 05:01 AM
  5. [SOLVED] Extracting an How to ArrayList from an ArrayList and convert to int??
    By igniteflow in forum Collections and Generics
    Replies: 2
    Last Post: August 16th, 2009, 01:11 PM

Tags for this Thread