Avatar of chand pb
chand pb
Flag for United States of America asked on

How to parse an xml string in Java

Hello,
 How can parse the XML string in java so that i get an arraylist...

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<Candidate>
      <EMPLID>1</EMPLID>
</Candidate>
<Candidate>
     <EMPLID>2</EMPLID>
</Candidate>
<Candidate>
     <EMPLID>3</EMPLID>
</Candidate>

Open in new window


I would like

arraylist[0] =
   <Candidate>
      <EMPLID>1</EMPLID>
</Candidate>

arraylist[1] =
  <Candidate>
      <EMPLID>2</EMPLID>
</Candidate>

arraylist[2]=
  <Candidate>
      <EMPLID>2</EMPLID>
</Candidate>

Thanks
Java

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
CEHJ

That's not actually xml - at least not well-formed xml. There is no root element
ASKER CERTIFIED SOLUTION
Jim Cakalic

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ

And i hope you haven't had to follow that suggestion, as you should have proper xml ;)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes