Hello everyone,
I’d like to know what is the optimal way to extract the value from the tag “decimal” from the following XML response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/\ “>
<s:Body>
<GetFileTotalValueByFileCodeResponse
xmlns="http://tempuri.org/\ ”>
<GetFileTotalValueByFileCodeResult
xmlns:a="http://schemas.datacontract.org/2004/07/WcfAbreuRPA.Business\ "
xmlns:i="http://www.w3.org/2001/XMLSchema-instance\ “>
<ErrorMessages
xmlns="http://schemas.datacontract.org/2004/07/WcfAbreuRPA.Entities.Base\ ”
xmlns:b="http://schemas.datacontract.org/2004/07/WcfAbreuRPA.Entities\ “/>
<TimeElapsedMessage i:nil="true"
xmlns="http://schemas.datacontract.org/2004/07/WcfAbreuRPA.Entities.Base\ ”/>
<a:FileValuesService
xmlns:b="http://schemas.datacontract.org/2004/07/System\ ">
<b:decimal>1231.870</b:decimal>
</a:FileValuesService>
</s:Body>
</s:Envelope>
My workflow is as follow:
HTTP Request → Output response to variable
Deserialize XML → Output to XDocument
Apologies if the solution is simple, I’ve been trying to access the different elements in the XML to get to the decimal value, but so far with no sucess.
Thank you.
ppr
(Peter Preuss)
February 4, 2021, 5:03pm
2
@andre.f.pires
as this XML is related to SOAP namespaces are defined for the elements and has to be handled.
Find some starter help here:
@Zlotzky
Setting up the quick prototype:
Variables:
Handling Namespace:
[grafik]
ElementNames to Extract - Prototype reduced set:
[grafik]
Read In XML
[grafik]
Ensure:
[grafik]
Retrieval of private contact element (mandatory use of the Namespace within the name)
[grafik]
iterating over the list of elmentnames (ExtractNames) and reading element value:
[grafik]
Logs:
[grafik]
Find starter help here:
Zlotzky.xaml (6.3 KB)
@Fabian_DDD
I do feel that a XPath Approach is better for the retrieval
Setting up a NamespaceManager with a Config Datatable:
[grafik]
for the default namespace with empty prefix “def” is assigne as prefix
the retrieval is configured as another datatable (could also be externalize into an excel)
[grafik]
I did also for a deeper nested element for demo purpose
After all preperation it is iterating over the retrieval config and retrieves the specfied values. et voila:
[grafik]
So this …
Hello Tim,
In this video, I use HTTP Request and extract XML from response:
23:50 Deserialize XML
25:15 How to extract Data from XML Nodes
27:40 How to extract Data from XML Attributes
Thanks,
Cristian Negulescu
Thank you for the suggestions everyone, but because I only want to extract a single value and the response body is static, I ended up using a simple REGEX expression to obtain the value. It’s not optimal, but it works for now.
Once again, I appreciate the help!
1 Like