I’m trying to read all xml files from my documents folder. I’ve tried to create an array of Objects (Xdocuments and XObjects too) and then read one by one using for each loop. This is not working, when I execute the robot it says “For Each: Unable to convert an object of type ‘System.String’ to type ‘System.Xml.Linq.XDocument’.”
for each’s type of argument is xdocument
Is there any other way to do this?
ppr
(Peter Preuss)
March 11, 2022, 11:52am
2
in case of you want to process all XML files within a for each then do following:
For each activity: item in Directory.GetFiles(“Path”, *.xml) | TypeArgument is string
Deserialize XML Activity | item | output: myXDoc - Datatype: XDocument
Do your processing with the myXDoc
It shows the message "
Deserialize XML: Invalid root-level data. Line 1, position 1."
(The output in Deserialize XML is xDoc)
1 Like
ppr
(Peter Preuss)
March 11, 2022, 12:22pm
4
looks like invalid XML and is independed from the suggestion / approach.
You can do following:
share this sample XML with us
validate the XML e.g. with the help of an online xml validator
ppr
(Peter Preuss)
March 11, 2022, 12:56pm
6
it was working with your sample:
can you crosscheck your Implementation on the read text file part?
After add Read text file activity it worked!
system
(system)
Closed
March 14, 2022, 2:38pm
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.