Extract information from XML
I have a response from a web request but I don't know how to extract the returned information.
Any clues?
-
Hi Robert,
While we don't have any activities specific to working with XML, you might be able to use the Regular Expression Replace and Text Replace activities to extract out the useful information, depending on what you are looking for. Make sure to set the Expect field in the Send Web Request to text.
Could you share some more information about your specific use case?
Thanks, Stefan
0 -
Hi, thanks again, the response from a webservice looks something like this and I am wanting to plot either the points as a line or a series of points, either good.
<route>
<summary>
<lengthInMeters>18558</lengthInMeters>
<travelTimeInSeconds>1643</travelTimeInSeconds>
</summary>
<leg>
<summary>
<lengthInMeters>2510</lengthInMeters>
<travelTimeInSeconds>416</travelTimeInSeconds>
</summary>
<points>
<point latitude="-37.81023" longitude="145.02851"/>
<point latitude="-37.81000" longitude="145.02855"/>
<point latitude="-37.80952" longitude="145.02859"/>
</points>
</leg>
<leg>
<summary>
<lengthInMeters>16048</lengthInMeters>
<travelTimeInSeconds>1227</travelTimeInSeconds>
</summary>
<points>
<point latitude="-37.79343" longitude="145.03146"/>
<point latitude="-37.79405" longitude="145.03132"/>
<point latitude="-37.79422" longitude="145.03128"/>
<point latitude="-37.79441" longitude="145.03124"/>
</points>
</leg>
</route>
0 -
Hi Robert,
I've tried using these methods however its a complicated process. I think it might be useful to create an request for this feature in the 'Ideas' section.
Thanks, Stefan
0 -
Oh sadly, I agree if it is difficult as I am sure it currently is, I think it's a significant oversight as I have several services that return xml and I am sure I am not the only one!
Thanks for your efforts, how did you approach it.
0 -
I was attempting to replace all tags and extraneous info by replacing them with spaces, then use the Parse Number to get the values, but this was unsuccessful.
0 -
This would fall apart a bit if you had any <point latitude=...> tags in your xml that you didn't want to be plotted, or if there are any other point properties that get placed in between the lat and long. But it works for the sample xml provided. I'm just using String split() to pull out the numbers from the places where we expect them to be.
0 -
Awesome works really well
0 -
Ok now I have been able to get back to it!
I have managed to create the point but now I need to exteract the 'leg' info and having no luck at all.
How can I extract these attributes?
<lengthInMeters>2545</lengthInMeters><travelTimeInSeconds>397</travelTimeInSeconds><trafficDelayInSeconds>0</trafficDelayInSeconds><departureTime>2017-12-11T15:52:28-08:00</departureTime><arrivalTime>2017-12-11T15:59:05-08:00</arrivalTime><noTrafficTravelTimeInSeconds>373</noTrafficTravelTimeInSeconds><historicTrafficTravelTimeInSeconds>397</historicTrafficTravelTimeInSeconds><liveTrafficIncidentsTravelTimeInSeconds>397</liveTrafficIncidentsTravelTimeInSeconds></summary><leg>
0 -
Hi Robert,
I don't think the method I used is super scale-able. We'd probably be able to work more smoothly with a JSON version. That being said, here's a quick edit that collects out the summary info, puts it into object properties (on $summaryInfo.result), and displays it on a form.
0 -
Hi Latitude, I'm wondering if there's a plan to add ability to read XML as object, so make it a bit possible to read and edit more complicated XML? thanks
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
10 commentaires