hangon
October 3, 2017, 3:59pm
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…
vvaidya
(Vinay Vaidya)
October 3, 2017, 8:19pm
2
Data = Ctype(myXML,IEnumerable(Of object))
2 Likes
hangon
October 3, 2017, 8:36pm
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
vvaidya
(Vinay Vaidya)
October 3, 2017, 8:37pm
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
hangon
October 3, 2017, 8:49pm
5
vvaidya:
IEnumerable
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…
vvaidya
(Vinay Vaidya)
October 3, 2017, 8:50pm
6
You won’t get intellisense for IEnumerable, but should work.
hangon
October 3, 2017, 8:57pm
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”
vvaidya
(Vinay Vaidya)
October 3, 2017, 9:02pm
8
Can you share screenshot of your variable.
hangon
October 3, 2017, 9:39pm
11
vvaidya:
IEnumerable<T>
I tried to pick that but while selecting that type it’s giving the attached error…
vvaidya
(Vinay Vaidya)
October 3, 2017, 9:44pm
12
Select Object from the dropdown.
1 Like
hangon
October 3, 2017, 9:52pm
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