You need to use XPath to do that, getElementsByTagName just supports specifying the actual tag name
http://www.ibm.com/develop
Main Topics
Browse All TopicsA String path = Address;
B String path = "//Company/GUIInputRequest
C String path = "/Company/GUIInputRequest/
D String path = "Company/GUIInputRequest/T
E String path = "Company/GUIInputRequest/T
F String path = "Company/GUIInputRequest/T
G String path = "Company/GUIInputRequest/T
I am trying to use the getElementsByTagName() method of the Document class to get at the root Node of XML as shown below in the code arbitrarily labeled '1'.
When I use line A to value the variable path (given the below XML), everything works fine.
However whenever I use any of the forms labeled B though G , I keep getting a NullPointerException at the code point that is labeled '2'
1 root = document.getElementsByTagN
2 Node element = root.item(0);
As you can see by the sample XML below, the element Party is a repeating element that can occur 1 to N times. I need to get at a specific instance of the element.
//////////////////////////
<Company>
- <GUIInputRequest>
- <TXLife>
- <TXLifeRequest>
<TransRefGUID>659</TransRe
<TransExeDate>2009-06-29</
<TransType tc="111">Illustration Request</TransType>
+ <OLifEExtension ExtensionCode="TXLifeReque
+ <IllustrationRequest>
- <OLifE>
<CurrentLanguage tc="9">English</CurrentLan
+ <PolicyProduct>
- <Holding>
<HoldingTypeCode tc="2">Policy</HoldingType
<HoldingStatus tc="3">Proposed</HoldingSt
<CurrencyTypeCode tc="840">US Dollars</CurrencyTypeCode>
+ <Policy>
</Holding>
+ <Party id="Client_1">
<Party id="Carrier">
<PartyTypeCode tc="2">Organization</Party
<FullName>Sample Life Insurance Company</FullName>
<ResidenceState tc="26">MA#Massachusetts</
<ResidenceCountry tc="1">USA#United States of America</ResidenceCountry>
- <Carrier>
<NAICCode>ZZZZZ9</NAICCode
</Carrier>
//////////////////////////
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.
You need to use XPath to do that, getElementsByTagName just supports specifying the actual tag name
http://www.ibm.com/develop
Business Accounts
Answer for Membership
by: dan4goodPosted on 2009-09-29 at 05:58:35ID: 25448443
oooops, I didn't quite get the whole XML stream.....Obviously sTypeCode>
<Carrier>
<NAICCode>ZZZZZ9</NAICCode>
</Carrier>
<Address>
<AddressTypeCode tc="27">Headquarters</Addres
<Line1>1295 State Street</Line1>
<City>Springfield</City>
<State>Massachusetts</State>
<Zip>01111-0001</Zip>
</Address>
</Party>
is needed as well.