Issue parsing XML file that is a saved as TXT
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Labels:
- Datasets
- Parse
- Transformation
- Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
the file is saved as TXT but has an XML structure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
Getting error "Error: XML Parse (2): invalid document structure at Line:3 and Column:7 at value"
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Just chiming in to support @danilang 's suggestion - I don't even see a line 3 in the screengrab....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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