XML question

I have some XML with the following structure:

cac:TaxTotal
cac:TaxSubtotal
cbc:TaxableAmount

I need to retrieve the cbc:TaxableAmount, which I do by iteratively picking each item using for each. So far, so good.

However; sometimes the XML has more than one of the third level item. Can anyone suggest how to A) Identify how many, and B) sum them together?

1 Like

@mickeymack
Can you Post some Sample XML from your scenario. I Could have later a Look on it

Of course - this is a sample of the XML and the relevant code bits; they won’t work ofc, but the whole files contains some sensitive information. XML.xaml (6.8 KB)

<cac:TaxTotal>
<cbc:TaxAmount currencyID=" **NOK** ">3671.84</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID=" **NOK** ">5648.80</cbc:TaxableAmount>
<cbc:TaxAmount currencyID=" **NOK** ">1412.20</cbc:TaxAmount>

For Mey ist OK the readcted Version. But please provide the top Elements information that are defining the Namespaces. This ist very imported to Proof that Code ist running sucessfully. Thanks

I’m not sure what you are asking? cac:Taxtotal is the first level.

I am talking about the XML parts on the top of file similar to <?xml version="1.0" encoding="UTF-8"?>

all the CBC,CAC etc definitions I do need to create a sample xml, same to your example

In the meanwhile you can have a look on this: How to extract multiples records in same XML file (with namespaces)?

xml_example.txt (2.3 KB)
Will this do?

Ok will use it, Thanks

1 Like

@mickeymack
PFA demo xaml: mickeymack2.xaml (8.6 KB)
I did some corrections on the XML and inserted a beginning invoiceLine element. This was correcting the structure as on end the closing tag was already present.
mickeymack.xml (2.2 KB)

Try to run my xaml standalone before integrating in your code. Adopt the XML Filepath accordingly before running the xaml

Let me know your open questions

Thanks mate - I’ll incorporate it in my code now. I’m afraid I can’t do anything to change the XML, that’s system generated.

@mickeymack
Your XAMl was not so far from the result. You are on a good track :+1:
In case of XML is System generated and you do need to do a fixing, you can do it on txt base level in advance before passing it ti Deserialize activity

Regex will do a good job and here in the forum there are a lot of brains very familiar with this. But please open for the XML correction task a new Post. So this Topic can cleaned finished and other members with XML questions can easy find the solution

When I pipe my XML-file into your file, it works correcly, so going to set this as solved - many thanks. I’m having some issues getting the correct sums when I incorporate it into my other code, but I’ll work on that tomorrow - on the tail end of a 17 hour day now. Thank you so much for all your help!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.