UiPath Documentation
activities
latest
false

Actividades de desarrollador

Última actualización 21 de abr. de 2026

Leer y deserializar un Archivo XML

El siguiente ejemplo explica cómo utilizar actividades como Deserializar XML, Ejecutar XPath, Obtener nodos XML u Obtener atributos de nodo XML para leer, deserializar, acceder y mostrar información diversa sobre un archivo XML. Puedes encontrar estas actividades en el paquete UiPath.WebAPI.Activities .

Nota:

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

Así es como se puede construir el proceso de automatización:

  1. Abre Studio y crea un nuevo Proceso.
  2. Arrastra un contenedor Secuencia al Diseñador de flujo de trabajo.
    • Crea las siguientes variables:

      Nombre de la variableTipo de variableValor predeterminado
      xmlCadena
      xmlDeserializedDocumentoX
      xml_xpath_resultObjeto
      xmlNodesIEnumerable
      xmlAttributesIEnumerable
      allExchRatesCadena
  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. Añade una actividad Deserializar XML después de la actividad Leer archivo de texto.
    • Add the variable xml in the XML String field.
    • In the Properties panel, add the variable xmlDeserialized in the XMLDocument.
  5. Añade una actividad Ejecutar XPath después de la actividad Deserializar 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. Añade una actividad Cuadro de mensaje después de la actividad Ejecutar XPath.
    • Añada la expresión "Exchange rates for " + xml_xpath_result.ToString en el campo Texto.
  7. Añade una actividad Obtener nodos XML después de la actividad Cuadro de mensaje.
    • Add the variable xmlDeserialized in the ExistingXML field.
    • In the Properties panel, add the variable xmlNodes in the XMLNodes field.
  8. Añade una actividad Obtener atributos de nodo XML después de la actividad Obtener nodos XML.
    • Add the expression xmlNodes(0) in the Existing XML Node field.
    • In the Properties panel, add the variable xmlAttributes in the Attributes field.
  9. Añade una actividad Cuadro de mensaje después de la actividad Obtener atributos de nodo XML.
    • Añada la expresión xmlAttributes(0).Name.Tostring + ": " + xmlAttributes(0).Value.Tostring en el campo Texto.
  10. Añade una actividad Asignar después de la actividad Cuadro de mensaje.
    • Añade la variable allExchRates en el campo Para.
    • Agrega la expresión "Exhange Rates" + System.Environment.NewLine en el campo Valor.
  11. Añade una actividad Para cada después de la actividad Asignar.
    • 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.
    • Añade la variable allExchRates en el campo Para.
    • Añade la siguiente expresión en el campo Valor : `allExchRates + System.Environment.NewLine + "1 " + item.Element("baseName").Value.ToString + " = " + item.Element("exchangeRate").Value. ACadena
      • " " + item.Element("targetName").Value.ToString`.
  13. Añade una actividad Cuadro de mensaje después de la actividad Para cada.
    • Agrega la variable allExchRates en el campo Texto.

  14. Ejecuta el proceso. Se lee, deserializa y accede al archivo XML. Se muestran algunos cuadros de mensaje con información extraída del archivo.

Aquí puedes descargar un ejemplo.

¿Te ha resultado útil esta página?

Conectar

¿Necesita ayuda? Soporte

¿Quiere aprender? UiPath Academy

¿Tiene alguna pregunta? Foro de UiPath

Manténgase actualizado