UiPath Documentation
activities
latest
false
Important :
Veuillez noter que ce contenu a été localisé en partie à l’aide de la traduction automatique. La localisation du contenu nouvellement publié peut prendre 1 à 2 semaines avant d’être disponible.
UiPath logo, featuring letters U and I in white

Activités du développeur.

Dernière mise à jour 21 avr. 2026

Lire et désérialiser un fichier 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.

Remarque :

Download and extract the archive with the project in this example and copy the file daily_usd.xml to your project folder.

Voici comment le processus d'automatisation peut être créé :

  1. Ouvrez Studio et démarrez un nouveau Processus.
  2. Faites glisser un conteneur Séquence vers le concepteur de workflow.
    • Créez les variables suivantes :

      Nom de variableTypes de variablesValeur par défaut
      xmlChaîne de caractères (string)
      xmlDeserializedDocumentX
      xml_xpath_resultObjet
      xmlNodesIEnumerable
      xmlAttributesIEnumerable
      allExchRatesChaîne de caractères (string)
  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. Add a Deserialize XML activity after the Read Text File activity.
    • Add the variable xml in the XML String field.
    • In the Properties panel, add the variable xmlDeserialized in the XMLDocument.
  5. Add an Execute XPath activity after the Deserialize XML activity.
    • 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. Add a Message Box activity after the Execute XPath activity.
    • Ajoutez l’expression "Exchange rates for " + xml_xpath_result.ToString dans le champ Texte.
  7. Add a Get XML Nodes activity after the Message Box activity.
    • Add the variable xmlDeserialized in the ExistingXML field.
    • In the Properties panel, add the variable xmlNodes in the XMLNodes field.
  8. 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 xmlAttributes in the Attributes field.
  9. Add a Message Box activity after the Get XML Node Attributes activity.
    • Ajoutez l’expression xmlAttributes(0).Name.Tostring + ": " + xmlAttributes(0).Value.Tostring dans le champ Texte.
  10. Add an Assign activity after the Message Box activity.
    • Ajoutez la variable allExchRates dans le champ À.
    • Ajoutez l’expression "Exhange Rates" + System.Environment.NewLine dans le champ Valeur.
  11. 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.
  12. Add an Assign activity inside the Sequence container of the For Each activity.
    • Ajoutez la variable allExchRates dans le champ À.
    • 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`.
  13. Add a Message Box activity after the For Each activity.
    • Ajoutez la variable allExchRates dans le champ Texte.

      image des documents

  14. Exécutez le processus. Le fichier XML est lu, désérialisé et accessible. Quelques boîtes de message s'affichent avec des informations extraites du fichier.

Ici, vous pouvez télécharger un exemple.

Cette page vous a-t-elle été utile ?

Connecter

Besoin d'aide ? Assistance

Vous souhaitez apprendre ? UiPath Academy

Vous avez des questions ? UiPath Forum

Rester à jour