activities
latest
false
- Visão geral
- Criptografia
- Banco de Dados
- Java
- Python
- WebAPI
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo.
A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.

Atividades do desenvolvedor
Última atualização 21 de abr de 2026
Ler e desserializar um arquivo XML
The following example explains how to use activities such as Deserialize XML, Execute XPath, Get XML Nodes, or Get XML Node Attributes for reading, deserializing, accessing, and displaying various information about an XML file. You can find these activities in the UiPath.WebAPI.Activities package.
Observação:
Download and extract the archive with the project in this example and copy the file daily_usd.xml to your project folder.
É assim que um processo de automação pode ser construído:
- Abra o Studio e crie um Processo.
- Arraste um contêiner Sequência para o Designer de Fluxo de Trabalho.
-
Crie as seguintes variáveis:
Nome da variável Tipo de Variável Valor Padrão xmlString xmlDeserializedXDocumentName xml_xpath_resultObject xmlNodesIEnumerable xmlAttributesIEnumerable allExchRatesString
-
- Add a Read Text File activity inside the Sequence.
- Add the expression
"daily_usd.xml"in the File Name field. - In the Properties panel, add the variable
xmlin the Content field.
- Add the expression
- Add a Deserialize XML activity after the Read Text File activity.
- Add the variable
xmlin the XML String field. - In the Properties panel, add the variable
xmlDeserializedin the XMLDocument.
- Add the variable
- Add an Execute XPath activity after the Deserialize XML activity.
- Add the variable
xmlDeserializedin the Existing XML field. - Add the expression
"string(/channel/lastBuildDate)"in the XPath Expression field. - In the Properties panel, add the variable
xml_xpath_resultin the Result field.
- Add the variable
- Add a Message Box activity after the Execute XPath activity.
- Adicione a expressão
"Exchange rates for " + xml_xpath_result.ToStringno campo Texto.
- Adicione a expressão
- Add a Get XML Nodes activity after the Message Box activity.
- Add the variable
xmlDeserializedin the ExistingXML field. - In the Properties panel, add the variable
xmlNodesin the XMLNodes field.
- Add the variable
- Add a Get XML Node Attributes activity after the Get XML Nodes activity.
- Add the expression
xmlNodes(0)in the Existing XML Node field. - In the Properties panel, add the variable
xmlAttributesin the Attributes field.
- Add the expression
- Add a Message Box activity after the Get XML Node Attributes activity.
- Adicione a expressão
xmlAttributes(0).Name.Tostring + ": " + xmlAttributes(0).Value.Tostringno campo Texto.
- Adicione a expressão
- Add an Assign activity after the Message Box activity.
- Adicione a variável
allExchRatesno campo Para. - Adicione a expressão
"Exhange Rates" + System.Environment.NewLineno campo Valor.
- Adicione a variável
- Add a For Each activity after the Assign activity.
- Add the expression
xmlDeserialized.Element("channel").Elements("item")in the Values field. - In the Properties panel, select the System.Xml.Linq.XElement option from the TypeArgument drop-down list.
- Add the expression
- Add an Assign activity inside the Sequence container of the For Each activity.
- Adicione a variável
allExchRatesno campo Para. - Add the following expression in the Value field: `allExchRates + System.Environment.NewLine + "1 " + item.Element("baseName").Value.ToString + " = " + item.Element("exchangeRate").Value.ToString
- " " + item.Element("targetName").Value.ToString`.
- Adicione a variável
- Add a Message Box activity after the For Each activity.
-
Adicione a variável
allExchRatesno campo Texto.
-
- Execute o processo. O arquivo XML é lido, desserializado e acessado. Algumas caixas de mensagem são exibidas com informações extraídas do arquivo.
Aqui você pode baixar um exemplo.