Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Read XML file with attributes

Hi, 

i have to map a xml-file, my problem is that this file contain attributes. Thie file look like this:

 <DeliveryItem>
<LineNo> 40.00</LineNo>
<PartId>
<IdentNo Domain="ET-NUMMER">961860800</IdentNo>
<IdentNo Domain="LIEFERANTENARTIKEL">4102-230V.O.61</IdentNo>
<IdentNo Domain="EAN">7611386037073</IdentNo>
</PartId>

How can i extract the values for ET-NUMMER, LIEFERANTENARTIKEL,EAN ? 

 

Second problem in the second line in the XML make reference to the .dtd file:

<!DOCTYPE BDD SYSTEM "ABB BDD.dtd">

But when i leave this line in i get no rows from talend.

 

Thanks for help

 

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

@drentsch, you can try this to extract the values,

 0683p000009LuqX.png0683p000009LuYS.png0683p000009Luqh.png

 Output:

.-------+------------------+--------------.
| tLogRow_1                               |
|=------+------------------+-------------=|
|LINE_NO|DOMAIN            |VALUE         |
|=------+------------------+-------------=|
|40.0 |ET-NUMMER           |961860800     |
|40.0 |LIEFERANTENARTIKEL  |4102-230V.O.61|
|40.0 |EAN                 |7611386037073 |
'-------+------------------+--------------'

View solution in original post

15 Replies
Anonymous
Not applicable
Author

@drentsch, you can try this to extract the values,

 0683p000009LuqX.png0683p000009LuYS.png0683p000009Luqh.png

 Output:

.-------+------------------+--------------.
| tLogRow_1                               |
|=------+------------------+-------------=|
|LINE_NO|DOMAIN            |VALUE         |
|=------+------------------+-------------=|
|40.0 |ET-NUMMER           |961860800     |
|40.0 |LIEFERANTENARTIKEL  |4102-230V.O.61|
|40.0 |EAN                 |7611386037073 |
'-------+------------------+--------------'

vapukov
Creator III
Creator III

just alternative way:

0683p000009LuVG.png

 

0683p000009LuWt.png

Anonymous
Not applicable
Author

Thanks, this is working fine
Anonymous
Not applicable
Author

Glad to hear that @drentsch

philippert
Contributor
Contributor

If you can't loop on the object, this syntaxe works too : IdentNo/@DOMAIN.

 

Thanks.

sushantk19
Creator
Creator

Hi All,

 

I have the below scenario:

 

output from my REST API is as below

|<?xml version="1.0" encoding="UTF-8"?>
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
<gesmes:subject>Reference rates</gesmes:subject>
<gesmes0683p000009M9p6.pngender>
<gesmes:name>European Central Bank</gesmes:name>
</gesmes0683p000009M9p6.pngender>
<Cube>
<Cube time='2020-03-24'>
<Cube currency='USD' rate='1.0843'/>
<Cube currency='JPY' rate='119.99'/>

<Cube currency='THB' rate='35.533'/>
<Cube currency='ZAR' rate='19.0754'/>
</Cube>
</Cube>
</gesmes:Envelope>|null |

 

I want to extract the values from two fields i.e currency and rate in two seperate fields in a .csv file.

currency    rate

USD          1.0843

JPY            119.99

 

Job design and configuration is attached which is not working as of now. I am very new to talend. can you please help?


Currency_extract2.png
vapukov
Creator III
Creator III

Hi,

 

try to use:

Loop XPath "gesmes:Envelope/Cube/Cube/Cube"

 

and XPath query:

"@currency"

"@rate"

 

regards

sushantk19
Creator
Creator

Unfortunately, no luck. same result.

 

-------+----.
| tLogRow_2 |
|=-------+---=|
|currency|rate|
|=-------+---=|
'--------+----'

[statistics] disconnected

vapukov
Creator III
Creator III

XML Field could be "string" (not the expected Body 🙂 )