• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Xpath - Multiple mapping issue

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my xml looks like below where different addresses are mapped using an ID within the same xml.

<test>
<state>
<stateCd>MA</stateCd>
<city>
<addressID>1</addressID>
</city>
<city>
<addressID>2</addressID>
</city>
<state>

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



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.

<xPath>//test/state/city/addressID/text()=../../address/@ID]</xPath>



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

Gokul
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is this xpath? and how come it can produce anything or "MA Address Line 1" as said at all?
 
Ranch Hand
Posts: 81
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Normally trees don't drive trucks. Does this tiny ad have a license?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic