# Reading XML files ... Flat File Document Parser ... problems !

**URL:** <https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405>\
**Category:** Node Development\
**Created:** [July 28, 2011, 3:11pm UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405 "2011-07-28T15:11:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucatoldo](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/57b2e6/32.png) [@lucatoldo](https://forum.knime.com/u/lucatoldo)\
**Post date:** [July 28, 2011, 3:11pm UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/1 "2011-07-28T15:11:52Z")

</div>

Dear All,

I got a folder with hundreds of XML that I need to process.

1. I've first tested if the format is okay, using the "XML Reader" and that give green light.

However, since "XML Reader" cannot read a directory of files, I've tried

a) . "Flat File Document Parser", followed by "String to XML" --\> Fails with console error  
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; column "Document" could not be parsed

b). "Flat File Document Parser", followed by "Document Data Extractor" configured with "Abstract" and "Text", followed by "String to XML" . Both using "Abstract" or using "Text" I get the same error "could not be parsed".

How can one read XML files in Knime ???

---

<div class="post-metadata">

**Author:** ![Iris](https://forum-cdn.knime.com/user_avatar/forum.knime.com/iris/32/14_2.png) [@Iris](https://forum.knime.com/u/Iris)\
**Post date:** [July 28, 2011, 4:21pm UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/2 "2011-07-28T16:21:38Z")

</div>

Hi,

&nbsp;

Using the list files node, you can create a list of all xml file names (in your folder)

Than use the iterate list of files meta node

Replace inside the meta node the variable based file reader with the xml reader.

Connect the loop start to the xml reader over flow variable port.

connect the xml out to the loop end.

&nbsp;

I also attach you the sample workflow :-)

&nbsp;

Cheers, Iris

- [readmultiplexml.zip](https://www.knime.com/sites/default/files/readmultiplexml.zip)

---

<div class="post-metadata">

**Author:** ![lucatoldo](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/57b2e6/32.png) [@lucatoldo](https://forum.knime.com/u/lucatoldo)\
**Post date:** [July 28, 2011, 9:57pm UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/3 "2011-07-28T21:57:18Z")

</div>

Thankyou Iris for your prompt and detailed reply, and for the example ! I will try it tomorrow morning !!

---

<div class="post-metadata">

**Author:** ![lucatoldo](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/57b2e6/32.png) [@lucatoldo](https://forum.knime.com/u/lucatoldo)\
**Post date:** [July 29, 2011, 8:17am UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/4 "2011-07-29T08:17:03Z")

</div>

Dear Iris,

It works perfectly well !!! Thankyou so much !!

With your example I've learned practically also

1) how to use the iterations

2)&nbsp;how to use the "Variable inport"

IMHO your example should be in a top tutorial page.

Thankyou so much !!!  
 Luca

---

<div class="post-metadata">

**Author:** ![ChrisFr](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/c/f475e1/32.png) [@ChrisFr](https://forum.knime.com/u/ChrisFr)\
**Post date:** [September 18, 2013, 2:36am UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/5 "2013-09-18T02:36:55Z")

</div>

Hello,

I try to use your advices and the IRIS' sample workflow but I'm facing a problem with the results of "Iterate List of files" node.

More precisely my problem is the following: I'm able to extract categories from one xml file in using xml reader, Xpath and ungroup nodes but when I tried to extract these same categories from the whole of xml files and that I use the list files and the iterate list of files nodes as in the IRIS'sample workflow, my collected results are not correct. I obtain the right number of rows (equal to iteration number or files in my folder) but it seems that information of only one xml file has been used. So after the iterate list of files node, if I try to parse each row with a Xpath node, the resulting output table has identical rows.

Here is attached my workflow file and 2 xml files.

Would you have an idea to resolve my problem ? What are the right options or basic settings to use in the "Variable Based File Reader" ?

Thank you. :)

&nbsp;

- [05-08-28-1745245.xml](https://www.knime.com/sites/default/files/05-08-28-1745245_0.xml)
- [05-08-29-0016236.xml](https://www.knime.com/sites/default/files/05-08-29-0016236_0.xml)
- [slashdot\_project\_dataloading.zip](https://www.knime.com/sites/default/files/slashdot_project_dataloading_0.zip)

---

<div class="post-metadata">

**Author:** ![Mrs\_Sippi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@Mrs\_Sippi](https://forum.knime.com/u/Mrs_Sippi)\
**Post date:** [September 25, 2015, 4:24pm UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/6 "2015-09-25T16:24:38Z")

</div>

How did you solve the problem with the various \<?xml?\> headers?

When I combine my xml files, the resulting document ( over 500 MB)&nbsp;contains the&nbsp;\<?xml?\> header from every single xml document.

---

<div class="post-metadata">

**Author:** ![Iris](https://forum-cdn.knime.com/user_avatar/forum.knime.com/iris/32/14_2.png) [@Iris](https://forum.knime.com/u/Iris)\
**Post date:** [October 1, 2015, 9:08am UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/7 "2015-10-01T09:08:07Z")

</div>

Hi Chris,

you cannot use the variable based file reader for reading a xml file. You need to use the xml reader, there go to the flow variable tab and select as file url the url flow variable.

If I do so the flow executes correctly. In slashdot the first columns are unique per file, only the last one have different&nbsp; values.

Best, Iris

&nbsp;

PS: You did see our white paper about slash dot data?

---

<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 23, 2023, 8:16pm UTC](https://forum.knime.com/t/reading-xml-files-flat-file-document-parser-problems/1405/8 "2023-06-23T20:16:24Z")

</div>


