How to convert xml to json

Hi all,

How to convert xml to json format. I cant use market packages is there any .net code available?

May we ask you to share some sample data (nput ixml, expected output json) with us?

@ppr sorry for that i can’t share the results it’s an confidential data

no problem, as you can share samples with redacted or anonymized data from which we can get the structures as well


If your xml is simple structure, the following might help you.

strJson = JsonConvert.SerializeXNode(xdoc, Newtonsoft.Json.Formatting.Indented)


strjson is of string type?
and I am geeting error
Message Box: An error occurred trying to start process ‘C:\Users\ajindal.nuget\packages\UiPath.system.activities\22.10.4\build\net461\WorkerProcess.exe’ with working directory ‘C:\Users\ajindal\Documents\E2e_rgc\End to End’. The filename or extension is too long.


For now, can you try to use WriteTextFile activity instead of MessageBox becuase the result might be too long.


Thanks for the help
It is working for now I am checking for the multiple files.

I am getting this error,
error BC30652: Reference required to assembly ‘System.Xml.XDocument, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ containing the type ‘XObject’. Add one to your project. XML Comparison.xaml.
I tried installing System.Xml.XDocument, but it was not getting installed.
Shows below error:
Package Installation Failure


What is XObject?


Are you importing any packages while using this function?
strJson = JsonConvert.SerializeXNode(xdoc, Newtonsoft.Json.Formatting.Indented)


Can you try to install UiPath.WebAPI.Activities package?


1 Like