Iterate XPath Result Object

activities
howto

#1

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…


#2

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


#3

appreciate the response…

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

Data variable what data type I need to define…

thanks


#4

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


#5

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…


#6

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


#7

tried in message box… with the following

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


#8

Can you share screenshot of your variable.


#9

Capture


#10

Select IEnumerable<T>


#11

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


#12

Select Object from the dropdown.


#13

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: