Hi,
I am trying to read the repeated elements of an XML. The part of the XML looks like ...
.......
.......
<Customer>
<Phone number="Home">5715271662</Phone>
<Phone number="Mobile">5715271663</Phone>
</Customer>
<Location>
<City name="One">Reston</City>
<City name="Two">Herndon</City>
</Location>
.......
.......
I am using the seqfile stage---> xml input stage ---> transformer ---> oracle stage
In the XML input stage, I gave the following XPaths (in description) to read those values. And mentioned the Phonetype as the repetitive element(Key).
Phonetype --> ....../Customer/Phone/@number
Number --> ....../Customer/Phone/text()
Citytype --> ...../Location/City/@schemeName
Cityname --> ...../Location/City/text()
but, it gives the output as
Phonetype Number Citytype Cityname
---------- ------- ---------- -------
Home 5715271662 One Reston
Mobile 5715271663 One Reston
I need the output as
Phonetype Number Citytype Cityname
---------- ------- ---------- -------
Home 5715271662 One Reston
Mobile 5715271663 Two Herndon
We cannot declare more than one key field. But, there should be someway to read them to get the mentioned output.
I am not sure whether to mention something in the derivation of the xml input stage.
Would anyone please help me out?
Thanks,
Swades
XML Input, Reading the repeated elements
Moderators: chulett, rschirm, roy
XML Input, Reading the repeated elements
Last edited by swades on Thu Jun 28, 2007 12:41 pm, edited 1 time in total.
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Try reading the XML with just 2 fileds:
And specify 'Phonetype' as repetition element.
Code: Select all
Phonetype --> ....../Customer/Phone/@number
Number --> ....../Customer/Phone/text()
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>