Skip to main content
Solved

How to extract information from xml block

  • February 21, 2025
  • 3 replies
  • 93 views

Forum|alt.badge.img+3

from above image i need to capture from “DatiGeneraliDocumento”
Data (Invoice Date)|
Numero (Invoice Number)|
ImportoTotaleDocumento |
and
from DatiDDT
Delivery number
Delivery Date

Best answer by jeven.delacruz

1) Read text from file "invoice.xml" into $sXMLContent$
2) XML > Load XML:
     - Source type: String
     - Source: $sXMLContent$
     - XML Object: $xmlInvoiceDoc$
3) XML > Get Single Node Value (Invoice Date):
     - XML Object: $xmlInvoiceDoc$
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiGeneraliDocumento/Data
     - Save to: $sInvoiceDate$
4) XML > Get Single Node Value (Invoice Number):
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiGeneraliDocumento/Numero
     - Save to: $sInvoiceNumber$
5) XML > Get Single Node Value (Invoice Total):
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiGeneraliDocumento/ImportoTotaleDocumento
     - Save to: $sInvoiceTotal$

6) XML > Get Multiple Node Values (all <DatiDDT>):
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiDDT
     - Save to: $nodeListDatiDDT$

7) LOOP: For each $currentDDT$ in $nodeListDatiDDT$
       a) XML > Get Single Node Value (Delivery Number):
          - Parent Node: $currentDDT$
          - XPath: NumeroDDT
          - Save to: $sDeliveryNumber$
       b) XML > Get Single Node Value (Delivery Date):
          - Parent Node: $currentDDT$
          - XPath: DataDDT
          - Save to: $sDeliveryDate$
       c) Log or store $sDeliveryNumber$ and $sDeliveryDate$ 
   END LOOP
 

 

3 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+14
  • Automation Anywhere Team
  • February 21, 2025

Consider using an online XPATH generator like this one:  https://extendsclass.com/xpath-tester.html

Paste your XML into the site and double-click on the XML tag. The XPATH shows up at the top of the page.

 


Forum|alt.badge.img+5
  • Navigator | Tier 3
  • Answer
  • February 25, 2025

1) Read text from file "invoice.xml" into $sXMLContent$
2) XML > Load XML:
     - Source type: String
     - Source: $sXMLContent$
     - XML Object: $xmlInvoiceDoc$
3) XML > Get Single Node Value (Invoice Date):
     - XML Object: $xmlInvoiceDoc$
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiGeneraliDocumento/Data
     - Save to: $sInvoiceDate$
4) XML > Get Single Node Value (Invoice Number):
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiGeneraliDocumento/Numero
     - Save to: $sInvoiceNumber$
5) XML > Get Single Node Value (Invoice Total):
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiGeneraliDocumento/ImportoTotaleDocumento
     - Save to: $sInvoiceTotal$

6) XML > Get Multiple Node Values (all <DatiDDT>):
     - XPath: /FatturaElettronicaBody/DatiGenerali/DatiDDT
     - Save to: $nodeListDatiDDT$

7) LOOP: For each $currentDDT$ in $nodeListDatiDDT$
       a) XML > Get Single Node Value (Delivery Number):
          - Parent Node: $currentDDT$
          - XPath: NumeroDDT
          - Save to: $sDeliveryNumber$
       b) XML > Get Single Node Value (Delivery Date):
          - Parent Node: $currentDDT$
          - XPath: DataDDT
          - Save to: $sDeliveryDate$
       c) Log or store $sDeliveryNumber$ and $sDeliveryDate$ 
   END LOOP
 

 


Forum|alt.badge.img+3
  • Author
  • Cadet | Tier 2
  • February 26, 2025

Thanks ​@jeven.delacruz  will try to implement this