XML Reading

Hi there, Im facing an issue reading XML, where the files have different tags, for example there is a Tag Named ICMS but then they add a number at the end, ICMS10, ICMS51, etc, and as far as I know that end number its really variable, but the content fields for those tags are standard for any ICMS “type” see the image below; is there a way of hadling this? like an option of “read all” or similar?

image

1 Like

here is the other example image

Could you provide us with a sample that best represents your problem? If you cannot share the data maybe you could use some dummy data.

2 Likes

20190613_31190659717553000617550020011878611005017709.xml (8.0 KB) 20190613_32190608800769000104550010000003821252821300.xml (51.5 KB)

as an example these two XML’s. The problem Im facing is that certain TAGs such as ICMSXXX can vary and this doesn’t depend on me, but I need to extract what’s inside that tag, and those never change…

Im trying to XML to JSON and work from there but glad to have any other perspectives

1 Like

Im thinking that maybe I can use something like adding asterisks or specific expression in the ICMS part, for example, This is one of the Tags I require, but in the section dns:ICMSSN102 the last part of the tag is variable SN102, here there are “n” cominiations

Original tag
/dns:nfeProc/dns:NFe/dns:infNFe/dns:det/dns:imposto/dns:ICMS/dns:ICMSSN102/dns:orig

Example
/dns:nfeProc/dns:NFe/dns:infNFe/dns:det/dns:imposto/dns:ICMS/dns:ICMS**/dns:orig

is that even posible?

1 Like

hello, have you had a chance to take a look? im still having hard time with this

1 Like

I started to check it out but as of now I do not have a solution. The relevant parts are buried deep inside the files.

1 Like

is it possible that in this file there is no path?

$['nfeProc']['NFe']['infNFe']['det']['imposto']['ICMS']

so in your example not only does this ICMS<xyz> passage differ?

1 Like

Hi @GQRanalytics,

you must use a single asterix

/dns:nfeProc/dns:NFe/dns:infNFe/dns:det/dns:imposto/dns:ICMS/*/dns:orig

but you can’t use this in the XML Reader. You have to use this in the XPath Node.

Best regards
Andrew

4 Likes

That is great @Andrew_Steel. XPath with an asterisk. I built a small workflow around the two sample files. It uses two steps of XPath - first to locate the overall ICMS part and then the sub-part with the single cells. Although I noticed changing cells so with more examples it might be necessary to extend that.

@GQRanalytics could you check if this suits your needs?

3 Likes

thank you very much, that actually worked :slight_smile:

2 Likes

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