XML Extract Data

Hello!
I have an XML in which I have to extract several tags

I need to filter this information in order to be able to assemble it in SQL.
I hope you can help me
This is my XML

Thanks.

@Beatriz_Eugenia_Duqu

lets assume the specific XML Values will be extracted and stored within an intermediate format (e.g. DataTable) for a later processing.

The Element “line” is a repeating element and occurrs in the sample 2 times (Quantitiy is to grab from this)

So we would assume that the XML extraction will produce 2 record sets.

Is this understanding matching your requirements? If not please elaborate on the exact output of this sample example.

Thanks

If it is totally as you describe it

Thanks

@Beatriz_Eugenia_Duqu

lets introduce an approach which is using datatables for configuring the extraction with the help of XPath:

Readin XML, parse to XObject (Ensure via dependency manager UiPath.WebApi.Acitivities is referenced):

grafik

Build the Extraction Config for the static part and the dynamic (lines) part:
grafik
grafik

add dynamicly the different columns to the extrac Datatable for later holding the extracted values:
grafik

Iterate of the extract config for the statics , extract the value and store it to a datarow (created with dtExtract.NewRow).
grafik

Retrieve all line elements:
grafik

  • iterate now over all line elements
  • create a DataRow (drExtractRow) for holding the extraction result
  • transfer with one go the extraction result of the statics to the drExtractRows
    drExtractRow.ItemArray = drStaticPart.ItemArray (So we can reuse the static part again without multiple redundant extractions)
  • iterate over the extraction config for the dynamics and extract the values
  • finally add drExtractRows to the Datatable dtExtract


grafik

as it was an adoption from here:

with the help of webtools (F12) in Browser the remaining XPath statements can be grabbed:

ensure also following:
grafik

Find starter help here:
StaticDynamicRetrieval_ByXpathConfig.xaml (17.9 KB)

1 Like