I’m trying to learn how to read and iterate though XML data using .element and .attribute and then for each loops e.g trying things like ‘XMLData(my variable).Element(“data”).Element(“columns”).Attribute(“Age”).ToString’
but I’ve noticed the XML data is set up slightly differently to what I’ve seen in that it has columns information then records (as opposed to ‘just records’.) So I’m guessing I could reference the ‘desired column index’ to get the info I need but I’m not sure how to do this.
Appreciate it’s a big ask but could anybody please guide me on what I would write to get specific data like a persons first and last name or their country.
The method you were using right and is the actual way of getting XML attribute value
Hmm do you mean like you need to access them with some other method
Thanks for replying. I wondered if there was a way you could use data from the ‘columns’ section to get the corresponding info required, if that makes sense.
This is something I explained in a previous forum post.
Attached is an example workflow which uses an XML file detailing some football fixture information. it provides the beginnings of how you access the data using UiPath.
Thank you so much for this. Runs really well and plenty for me to learn from. I’m going to see if I can split the data for each person (for example ‘38Canada15/10/2017DulceFemale15522Abril’) in to it’s constituent parts and put it all in an array or datatable, something like that under the correct column headings. Please can I ask, would you recommend the best way to do this is to split the records up in to an array then add them to a datatable with the column headers already set? or would you approach this a different way?
That was a great question and it is very exciting to answer.
You have two ways to do that.
you can directly write the columns as columns into Excel and data in the respective rows using Excel activities by just looping as the above workflow
Or
you can use build data table activities and add the headings of the columns using add data column and the respective data of the entire record using add data rows…
My colleague helped me look at the XML xaml you’d kindly built for me and had a play around with it. Here is the output which gets the data and puts it in to a datatable ready for an excel file, just in case you want to take a look
Thanks again
Jordan
It helps the forum users if any one wants to do the same…
The thing is, as per the forum rules, we are not supposed to provide the workflows as a solution. But explaining the design of a XML workflow is difficult. So, i added the workflow but writing it to an excel is an easy thing. So, I just guided you to do that