File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Xpath - Multiple mapping issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Xpath - Multiple mapping issue" Watch "Xpath - Multiple mapping issue" New topic

Xpath - Multiple mapping issue

Gokul Mahalingam

Joined: Aug 20, 2013
Posts: 1
my xml looks like below where different addresses are mapped using an ID within the same xml.


<address ID=1>
<line1>Address line 1</line1>
<address ID =2>
<line1>Address line 2</line1>

I need read and display as below

MA Address Line 1
MA Address Line 2

but I am getting:

MA Address Line 1
MA Address Line 1

I am using below xpath to map the addresses.


Any help or suggestion would be really appreciated. Thanks in advance.

g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 632

What is this xpath? and how come it can produce anything or "MA Address Line 1" as said at all?
Santhosh ayiappan
Ranch Hand

Joined: Jan 30, 2007
Posts: 80

Can you try something like this ?

Use the for-each block to iterate the Address and use something like position() to get the correct values
I agree. Here's the link:
subject: Xpath - Multiple mapping issue
It's not a secret anymore!