UiPath Documentation
activities
latest
false
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.
UiPath logo, featuring letters U and I in white

Atividades do desenvolvedor

Última atualização 21 de abr de 2026

Ler e desserializar um arquivo XML

O exemplo a seguir explica como usar atividades como Deserialize XML, Execute XPath, Get XML Nodes ou Get XML Node Attributes para ler, desserializar, acessar e exibir várias informações sobre um arquivo XML. Você pode encontrar essas atividades no pacote UiPath.WebAPI.Activities .

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:

  1. Abra o Studio e crie um Processo.
  2. Arraste um contêiner Sequência para o Designer de Fluxo de Trabalho.
    • Crie as seguintes variáveis:

      Nome da variávelTipo de VariávelValor Padrão
      xmlString
      xmlDeserializedXDocumentName
      xml_xpath_resultObject
      xmlNodesIEnumerable
      xmlAttributesIEnumerable
      allExchRatesString
  3. 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 xml in the Content field.
  4. Adicione uma atividade Deserialize XML após a atividade Read Text File.
    • Add the variable xml in the XML String field.
    • In the Properties panel, add the variable xmlDeserialized in the XMLDocument.
  5. Adicione uma atividade Execute XPath após a atividade Deserialize XML.
    • Add the variable xmlDeserialized in the Existing XML field.
    • Add the expression "string(/channel/lastBuildDate)" in the XPath Expression field.
    • In the Properties panel, add the variable xml_xpath_result in the Result field.
  6. Adicione uma atividade Message Box após a atividade Execute XPath.
    • Adicione a expressão "Exchange rates for " + xml_xpath_result.ToString no campo Texto.
  7. Adicione uma atividade Get XML Nodes após a atividade Message Box.
    • Add the variable xmlDeserialized in the ExistingXML field.
    • In the Properties panel, add the variable xmlNodes in the XMLNodes field.
  8. Adicione uma atividade Get XML Node Attributes após a atividade Get XML Nodes.
    • Add the expression xmlNodes(0) in the Existing XML Node field.
    • In the Properties panel, add the variable xmlAttributes in the Attributes field.
  9. Adicione uma atividade Message Box após a atividade Get XML Node Attributes.
    • Adicione a expressão xmlAttributes(0).Name.Tostring + ": " + xmlAttributes(0).Value.Tostring no campo Texto.
  10. Adicione uma atividade Assign após a atividade Message Box.
    • Adicione a variável allExchRates no campo Para.
    • Adicione a expressão "Exhange Rates" + System.Environment.NewLine no campo Valor.
  11. Adicione uma atividade For Each após a atividade Assign.
    • 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.
  12. Add an Assign activity inside the Sequence container of the For Each activity.
    • Adicione a variável allExchRates no campo Para.
    • Adicione a seguinte expressão no campo Valor : `allExchRates + System.Environment.NewLine + "1 " + item.Element("baseName").Value.ToString + " = " + item.Element("exchangeRate").Value. ParaString
      • " " + item.Element("targetName").Value.ToString`.
  13. Adicione uma atividade Message Box após a atividade For Each.
    • Adicione a variável allExchRates no campo Texto.

      Imagem dos documentos

  14. 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.

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades