Need help with Invoke Method WriteXml from Data Table

Good evening UiPath Forum, I have a use case where financial data will need to be output to an XML file for processing into an API. I have lined up the necessary information in a data table. I am trying to output to an XML file using the Invoke Method Activity. It’s the Parameters and Arguments (if needed) that I would appreciate your help with. Thanks as always UiPath Forum.

Hi, @jamiejam

Set your Invoke Method’s TargetObject to your DataTable variable (not string), MethodName to WriteXml and Parameter as In, Type=String, Value set to your XML file path e.g: (“C:\Temp\dt_XML_Output.xml”); leave TargetType blank

Big thanks @arjun.shiroya for the fast reply. Worked first time. If you don’t mind, I had a few questions on the output. Thanks again.

  1. Are there steps I can take in UiPath to rename the elements. You’ll see below that it says and . Can I control how they are named by UiPath so I could name them how the API is expecting them or do I need take the XML and deserialize / reserialize?

  2. The activity put a string in all the lines of the file. Is there a way I can generate the XML without that? “xmlns:xs=“XML Schema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:type=“xs:string” xs:xmlns=“xs:string””.

Hi, @jamiejam Thanks for your feedback!

You can’t directly change element names or remove schema attributes using WriteXml; use “Invoke Code” or LINQ/XML activities to build the XML manually for custom tags and clean output..I think this is best way to match API requirements and avoid unwanted xmlns, xsi tags

1 Like

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