Iterate XPath Result Object

I have to iterate on the result of “Execute XPath” Activity.
The challenge I’m facing is the Execute XPath returns “Object” Datatype.

  • How to validate the returned Object has data ? I tried to do ToString but it does not give me any readable text…
  • For which datatype I need to cast this to so that I can iterate and get values

My XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TestRoot>
	<Data>
		<Item>1</Item>
		<Item>1</Item>
		<Item>1</Item>
		<Item>1</Item>
	</Data>
</TestRoot>

Xpath Expression : /TestRoot/Data/Item

I have tested my xml and xpath expression in freeformatter and it works…

Data = Ctype(myXML,IEnumerable(Of object))

2 Likes

appreciate the response…

so “myXML” is the “variable of the output of Xpath Actiity”

Data variable what data type I need to define…

thanks

Yes.

IEnumerable — select object from drop down

You could either iterate data using for each object

Or

Data(1).ToString for individual values

Data.Count.ToString gives the count

I’m sure I’m doing something wrong…

I have defined a variable called “Data” with the Systems.Collections.IEnumerable
I have used assign activity Data = Ctype(xmlObject,IEnumerable(Of object))
I have created a message box… but there are no methods like “Count” in Data object variable…

You won’t get intellisense for IEnumerable, but should work.

tried in message box… with the following

Data.Count.ToString but the activity shows as error with “Count is not a member of IEnumerable”

Can you share screenshot of your variable.

Capture

Select IEnumerable<T>

I tried to pick that but while selecting that type it’s giving the attached error…

Select Object from the dropdown.

1 Like

super… thanks for your patience… now I can get access to the content and was able to print it out… … really appreciate your response and your patience :slight_smile: