# XML Reading

**URL:** <https://forum.knime.com/t/xml-reading/26995>\
**Category:** KNIME Analytics Platform\
**Created:** [September 8, 2020, 3:13pm UTC](https://forum.knime.com/t/xml-reading/26995 "2020-09-08T15:13:10Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![GQRanalytics](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/ee7513/32.png) [@GQRanalytics](https://forum.knime.com/u/GQRanalytics)\
**Post date:** [September 8, 2020, 3:13pm UTC](https://forum.knime.com/t/xml-reading/26995/1 "2020-09-08T15:13:10Z")

</div>

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](https://forum-cdn.knime.com/uploads/default/original/3X/4/3/43f53083ffe3dc64774e917245cf367cf32fc281.png)

---

<div class="post-metadata">

**Author:** ![GQRanalytics](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/ee7513/32.png) [@GQRanalytics](https://forum.knime.com/u/GQRanalytics)\
**Post date:** [September 8, 2020, 3:14pm UTC](https://forum.knime.com/t/xml-reading/26995/2 "2020-09-08T15:14:44Z")

</div>

here is the other example ![image](https://forum-cdn.knime.com/uploads/default/original/3X/2/6/2646d7be60214f16769297988fb10d98650c9718.png)

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [September 9, 2020, 3:21pm UTC](https://forum.knime.com/t/xml-reading/26995/3 "2020-09-09T15:21:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GQRanalytics](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/ee7513/32.png) [@GQRanalytics](https://forum.knime.com/u/GQRanalytics)\
**Post date:** [September 10, 2020, 4:54pm UTC](https://forum.knime.com/t/xml-reading/26995/4 "2020-09-10T16:54:00Z")

</div>

[20190613\_31190659717553000617550020011878611005017709.xml](https://forum.knime.com/uploads/short-url/igEU2R6V84OxzmRYxhiIOeuxWms.xml) (8.0 KB) [20190613\_32190608800769000104550010000003821252821300.xml](https://forum.knime.com/uploads/short-url/zxEwQClscWDNIBYMVknAAZJzsBY.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

---

<div class="post-metadata">

**Author:** ![GQRanalytics](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/ee7513/32.png) [@GQRanalytics](https://forum.knime.com/u/GQRanalytics)\
**Post date:** [September 11, 2020, 2:37pm UTC](https://forum.knime.com/t/xml-reading/26995/5 "2020-09-11T14:37:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![GQRanalytics](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/ee7513/32.png) [@GQRanalytics](https://forum.knime.com/u/GQRanalytics)\
**Post date:** [September 17, 2020, 4:41pm UTC](https://forum.knime.com/t/xml-reading/26995/6 "2020-09-17T16:41:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [September 17, 2020, 5:03pm UTC](https://forum.knime.com/t/xml-reading/26995/7 "2020-09-17T17:03:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [September 18, 2020, 2:01pm UTC](https://forum.knime.com/t/xml-reading/26995/8 "2020-09-18T14:01:04Z")

</div>

> [@GQRanalytics](#):
>
> [20190613\_32190608800769000104550010000003821252821300.xml](https://forum.knime.com/uploads/short-url/zxEwQClscWDNIBYMVknAAZJzsBY.xml) (51.5 KB)

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?

---

<div class="post-metadata">

**Author:** ![Andrew\_Steel](https://forum-cdn.knime.com/user_avatar/forum.knime.com/andrew_steel/32/4472_2.png) [@Andrew\_Steel](https://forum.knime.com/u/Andrew_Steel)\
**Post date:** [September 18, 2020, 3:24pm UTC](https://forum.knime.com/t/xml-reading/26995/9 "2020-09-18T15:24:17Z")

</div>

Hi @GQRanalytics,

> [@GQRanalytics](#):
>
> /dns:nfeProc/dns:NFe/dns:infNFe/dns:det/dns:imposto/dns:ICMS/dns:ICMS\*\*/dns:orig

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

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [September 18, 2020, 4:07pm UTC](https://forum.knime.com/t/xml-reading/26995/10 "2020-09-18T16:07:14Z")

</div>

> [@Andrew\_Steel](#):
>
> you must use a single asterix

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?

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/f/a/fa877e656b38e29e539f4fe4dfca5d60398a9ee1.png)

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/c/a/ca300b613e92e47cafe44a6767d983e05f4a0a94.png)

> **[Load a collection of XML files with one changing item with the help of nested...](https://hub.knime.com/mlauber71/spaces/Public/forum/kn_forum_26995_xml_read_changing_cells~y1TfwGSJfPaspGfb/current-state)**
>
> Load a collection of XML files with one changing item with the help of nested XPath definitions

---

<div class="post-metadata">

**Author:** ![GQRanalytics](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/ee7513/32.png) [@GQRanalytics](https://forum.knime.com/u/GQRanalytics)\
**Post date:** [December 8, 2020, 10:51pm UTC](https://forum.knime.com/t/xml-reading/26995/11 "2020-12-08T22:51:08Z")

</div>

thank you very much, that actually worked 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 9, 2021, 10:51am UTC](https://forum.knime.com/t/xml-reading/26995/12 "2021-06-09T10:51:08Z")

</div>

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