or start looking at -
http://www.developerfusio
Main Topics
Browse All TopicsGiven the following XML:
<Coverage id="Base">
<PlanName>Whole Life</PlanName>
<Purpose tc="1">None</Purpose>
<ShortName>WL100</ShortNam
<MarketingName>Legacy 100 Whole Life</MarketingName>
<LifeCovTypeCode tc="1">Whole Life Ordinary</LifeCovTypeCode>
<ProductCode>W070002290</P
<IndicatorCode tc="1">Base</IndicatorCode
<LifeCovStatus tc="12">Proposed</LifeCovS
<LineOfBusiness tc="1">Life</LineOfBusines
<ProductVersionCode>1</Pro
<PaymentMode tc="4">M#Monthly</PaymentM
<ModalPremAmt>205.50</Moda
<EffDate>2009-06-26</EffDa
</Coverage>
<Coverage id="LISR">
<PlanName>Life Insurance Supplement Rider</PlanName>
<ShortName>LISR</ShortName
<MarketingName>Life Insurance Supplement Rider(LISR)</MarketingName
<LifeCovTypeCode tc="24">Flexible Additional Insurance</LifeCovTypeCode
<ProductCode>L070102294</P
<IndicatorCode tc="4">Integrated</Indicat
<LifeCovStatus tc="12">Proposed</LifeCovS
<LineOfBusiness tc="1">Life</LineOfBusines
<ProductVersionCode>1</Pro
<EffDate>2009-06-26</EffDa
</Coverage>
<Coverage id="ALIR">
<PlanName>Adjustable Life Insurance Rider</PlanName>
<ShortName>ALIR</ShortName
<MarketingName>Adjustable Life Insurance Rider(ALIR)</MarketingName
<LifeCovTypeCode tc="1013200003">Adjustable
<ProductCode>A070002293</P
<IndicatorCode tc="2">Rider</IndicatorCod
<LifeCovStatus tc="12">Proposed</LifeCovS
<LineOfBusiness tc="1">Life</LineOfBusines
<ProductVersionCode>1</Pro
<EffDate>2009-06-26</EffDa
</Coverage>
I want to get all 3 element values from the XML and populate a Java object with a similar structure(within the class called 'coverageObj ' in the sample code). How do you get at all the instances of a repeating element using DOM's getElementsByTagName method.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
or start looking at -
http://www.developerfusio
You should probably be looking at something like JAXB
https://jaxb.dev.java.net/
XPath seems best fit for this...
check this example http://www.roseindia.net/t
jagadeesh, I think that will example will do and best fits what currently exists within the codebase. I will try it and post back later today.
CEHJ: I also am going to look at JAXB and let you know.
ksivananth: I already developed a complete solution using XPath and although it is a much cleaner implementation, and doesn't come cliose from a performance perspective.
works perfectly. here is the new implementation...
public static Coverage[] getFieldValues(Context cxt)
{
List<Coverage> dataContainer = new ArrayList<Coverage>();
List<SystemElement> attributeList = null;
Coverage[] allCoverage = null;
Coverage instCoverageObj = null;
NodeList rootElement = null;
if (cxt != null) {
try{
Document document = cxt.getPersistenceEngine()
rootElement = document.getElementsByTagN
int totalCoverages = rootElement.getLength();
Node baseElement = rootElement.item(0);
for(int s=0; s < totalCoverages ; s++){
//////////////////////////
Node coverageNode = rootElement.item(s);
instCoverageObj = new Coverage();
attributeList = getChildAttributes(baseEle
setChildAttributes(instCov
if(coverageNode.getNodeTyp
Element coverageElement = (Element)coverageNode;
NodeList marketingNameList = coverageElement.getElement
Element marketingNameElement = (Element)marketingNameList
instCoverageObj.setMarketi
NodeList shortNameList = coverageElement.getElement
Element shortNameElement = (Element)shortNameList.ite
instCoverageObj.setShortNa
NodeList lineOfBusinessList = coverageElement.getElement
Element lineOfBusinessElement = (Element)lineOfBusinessLis
instCoverageObj.setLineOfB
attributeList = getChildAttributes(lineOfB
setChildAttributes(instCov
//-------now do rest of fields not shown for brevity
/**
* Once all element values for object are resolved....look at it child element nodelist
*/
NodeList lifeParticipantList = coverageElement.getElement
LifeParticipant lifeParticipant = LifeParticipant.getFieldVa
instCoverageObj.setLifePar
attributeList = getChildAttributes(lineOfB
setChildAttributes(instCov
NodeList covOptionList = coverageElement.getElement
CovOption covOption = CovOption.getFieldValues(c
instCoverageObj.setCovOpti
attributeList = getChildAttributes(lineOfB
setChildAttributes(instCov
NodeList oLifEExtensionList = coverageElement.getElement
OLifEExtension oLifEExtension = OLifEExtension.getFieldVal
instCoverageObj.setOLifEEx
attributeList = getChildAttributes(lineOfB
setChildAttributes(instCov
dataContainer.add(instCove
}//end of if clause
}//end of for loop
} catch (Exception e) {
e.printStackTrace();
}
}
Business Accounts
Answer for Membership
by: jagadeesh_motamarriPosted on 2009-10-13 at 13:23:54ID: 25564129
can you post code for your Coverage class ?