How to create/generate XML out of datatable


Please guide me as to how do I create XML file out of datatable that I build run time.



Thanks vvaidya for quick response and help. I am getting following warning/error. Could you please guide me whether I am doing anything wrong? Also please note that Arguments Panel picture that I see in your example and one I get on “UiPath Community Edition” is different. Is that an issue?


“sw” should be passed as a parameter in Invoke method properties, you passed it as an argument

Thanks buddy, that worked.

I missed asking, how do I put it a particular format of XML nodes and how do I write it to a file to create xyz.xml?

Thanks again

Might look complex with all those Invoke Methods (but not), let me know if it works.

dt2Xml-1.xaml (11.3 KB)


This was AWESOME! Thanks for the project file!

1 Like

Hi Vaidya,

How you doing?

Few hurdles in creating XML, if you could help me out on this one.
I need to create XML tag as,



XML Naming Rules

XML elements must follow these naming rules:

Names can contain letters, numbers, and other characters
Names cannot start with a number or punctuation character
Names cannot start with the letters xml (or XML, or Xml, etc)
Names cannot contain spaces
Any name can be used, no words are reserved

Thanks a lot buddy.

Hi All,

Have done some trials on DataScapping/DB/Excel interaction etc…so far.
Have a typical issue of creating XML…I found this item on forum and felt very similar to my issue.
i prefer to keep the tags and values in Excel.(I assume file - file123.xlsx in the example is for this purpose).
What is the sample format of my Excel (in terms of nodes and values)?
what are the packages i should import in order to work the attached file smoothly?
(I do not see the most of the methods in the activity list).
invokemethod() function definitions - Should I do any programming ( for WriteStartDocument/WriteStartElement…etc) or just use the thread as it is…?
Am a BA with minimum programming skills…
I was able to understand that pgm reads the sheet1 of the file and store into datatable. Subsequently loops thru the DT and do the XML processing.
pls help me on this…btw, can you pls share tutorial , if any available.

Thanks in advance.

For me it’s not writing anything.:frowning:

Hi @vvaidya ,
While creating xml I am getting some extra attributes like xmlns xmlns:xsi=“” xmlns:xs=“XML Schema” xsi:type=“xs:string”

How I can remove this.?

I need to create an xml file, based on multiple columns in database/excel/datatable.
But unable to find a solution. I have tried above steps, but getting an error for WriteXML method. Have also added Activities required for xml. Please suggest on how to resolve it.

Hi @ManojK,

There are Two ways:

  1. You can use XMLwriter, or you can use serialization.
  2. I’d recommend serialization, but if it is simple, use XmlDocument, like this:

Have attached the sample workflow all you need to do is import you data table as argument in the invoke code and manipulate the elements by changing their appropriate names

a (2).xaml (8.7 KB)

Thanks & regards
Sanjay Shankhla