Parse XML and Create List From Unique Values
I am building a workflow that requests all the routes in state from our LRS server, returns the values in string format. From there, I want create a list of unique values that is returned and add that back into a Form and use it to populate a ListBox.
Here's what I have so far:
Using the 'Download String' tool, I get the following returned (Note: This is a very shortened list. Over 300 total returns.):
<Route>
<RouteID>1000006</RouteID>
<RouteSystemID>1</RouteSystemID>
<AssignedRoutesID>6</AssignedRoutesID>
<GeographicExtentID>718</GeographicExtentID>
<RouteName>235</RouteName>
<RouteDirection>W</RouteDirection>
<FullName>I 235 W</FullName>
<OfficialName>STATE OF IOWA, I 235 W</OfficialName>
</Route>
<Route>
<RouteID>7</RouteID>
<RouteSystemID>1</RouteSystemID>
<AssignedRoutesID>7</AssignedRoutesID>
<GeographicExtentID>718</GeographicExtentID>
<RouteName>280</RouteName>
<RouteDirection>E</RouteDirection>
<FullName>I 280 E</FullName>
<OfficialName>STATE OF IOWA, I 280 E</OfficialName>
</Route>
<Route>
<RouteID>1000007</RouteID>
<RouteSystemID>1</RouteSystemID>
<AssignedRoutesID>7</AssignedRoutesID>
<GeographicExtentID>718</GeographicExtentID>
<RouteName>280</RouteName>
<RouteDirection>W</RouteDirection>
<FullName>I 280 W</FullName>
<OfficialName>STATE OF IOWA, I 280 W</OfficialName>
</Route>
<Route>
<RouteID>1</RouteID>
<RouteSystemID>1</RouteSystemID>
<AssignedRoutesID>1</AssignedRoutesID>
<GeographicExtentID>718</GeographicExtentID>
<RouteName>29</RouteName>
<RouteDirection>N</RouteDirection>
<FullName>I 29 N</FullName>
<OfficialName>STATE OF IOWA, I 29 N</OfficialName>
I want to parse out just the "Full Name" values. Using the Assign command and this statement, I can parse out <FullName></FullName> values. The variable strResults is used to store the results from the 'Download String' tool.
strResults.Substring(strResults.IndexOf("<FullName>") + "<FullName>".Length, strResults.IndexOf("</FullName>") - strResults.IndexOf("<FullName>") - "<FullName>".Length)
This will only return the first value. I am stuck on how to read the (~300 unique values) and add them to a list. I also tried converting the string results to a XDocument but I was stuck on how to parse out each unique value.
I assume I need to use a For Each statement, but can't figure it out. Any help would appreciated.
Thanks!
-
How did you get the actual XML from the download string? I'm loading the xml feed address into the download string but am getting the configuration, not the actual response. 0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar