Hi,
I am unable to parse XML file that we received from a server. the file is saved as XXX.xml.txt
below is my workflow, config settings and errors.
Solved! Go to Solution.
Hi,
the file is saved as TXT but has an XML structure.
Hey @Wafarian, if you pull on an Input Data tool and then choose your file, you can still just select to read it in as an XML from the dropdown, even though it's a .txt - see here:
@Wafarian I'm not too experienced working with XML but because of the nesting I think you may need to do an initial parse of your field for the <Item> tag - you can search for a specific child by using this configuration like so:
The resulting fields of that should then have the <Amount> data, that you can use a second XML Parse tool to go over. In this example the <Fields> data that's nested within the configuration would be what I'd parse in my second tool:
Hi @Wafarian
Can you attach the actual xml file, as opposed to an image of it? The error messages suggest that the file is badly structured, but it looks correct in the image.
Thanks
Dan
Just chiming in to support @danilang 's suggestion - I don't even see a line 3 in the screengrab....
Hi,
I am not able to attached the file due to file extension .XML.TXT
However, below is the sample file
____________________________________________________________________________
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<AmountList>
<Envelope>
<Version>1.0</Version>
<SenderID>777</SenderID>
<ReceiverID>666</ReceiverID>
<TransactionID>4444</TransactionID>
</Envelope>
<Head>
<CurrencyCode>ZAM</CurrencyCode>
<Date>2023-05-05</Date>
<ValidityAreas>
<ValidityArea>AREA</ValidityArea>
</ValidityAreas>
</Head>
<Items>
<Item>
<MatID>FFFF</MatID>
<Code>11551</Code>
<Description>Soya</Description>
<Amount>
<Price>
<ValidFrom>2023-05-05</ValidFrom>
<ValidTo>9999-12-31</ValidTo>
<Price>50.00</Price>
</Price>
</Amount>
</Item>
<Item>
<MatID>XXXX</MatID>
<Code>111</Code>
<Description>Milk</Description>
<Amount>
<Price>
<ValidFrom>2023-05-05</ValidFrom>
<ValidTo>9999-12-31</ValidTo>
<Price>10.00</Price>
</Price>
</Amount>
</Item>
</Items>
</AmountList>
Hi,
the file is an xml file but the extension is TXT and that is how we receive it from the business. It is the TXT extension that is causing the problem.
What I actually need from the file is this section
<Items>
<Item>
<MatID>FFFF</MatID>
<Code>11551</Code>
<Description>Soya</Description>
<Amount>
<Price>
<ValidFrom>2023-05-05</ValidFrom>
<ValidTo>9999-12-31</ValidTo>
<Price>50.00</Price>
</Price>
</Amount>
</Item>
<Item>
<MatID>XXXX</MatID>
<Code>111</Code>
<Description>Milk</Description>
<Amount>
<Price>
<ValidFrom>2023-05-05</ValidFrom>
<ValidTo>9999-12-31</ValidTo>
<Price>10.00</Price>
</Price>
</Amount>
</Item>
</Items>
I only need the data from the <Items> </Items> section
User | Count |
---|---|
19 | |
14 | |
13 | |
9 | |
8 |