Reading all the tags of an XML and take them to excel

Hello,

I am too new to UIPATH and I am trying to do an XML reading project and take a document in excel. so far he managed to get me to read some XML tags.

I have trouble reading some labels

example these:

<cbc:CompanyID schemeAgencyID=“195” schemeID=“0” schemeName=“31”>NIT PROVEEDOR</cbc:CompanyID>
<cbc:CompanyID schemeAgencyID=“195” schemeID=“0” schemeName=“31”>NIT CLIENTE</cbc:CompanyID>
cac:SellersItemIdentificationcbc:ID20001427</cbc:ID></cac:SellersItemIdentification>
cbc:DescriptionPRUEBA PRUEBA</cbc:Description>
<cbc:BaseQuantity unitCode=“94”>1</cbc:BaseQuantity>
7. Valor total de la operación
ValTolFac:
8. FORMA DE PAGO
cbc:NoteNOTA</cbc:Note>cbc:Note
The other thing is that I cannot find for what reason that at a time when you are storing the information in excel it throws the following error:

Escribir celda: Mensaje de error original: Excepción de HRESULT: 0x800401A8

project
Lector.xaml (15.5 KB)

Document:
Data1.xml (32.1 KB)

Thank you

@Fabian_DDD
Ok telling you that you are dealing with namespace is obsolete :slight_smile:
I dont speak your language and have to do transfer to other european languages. It seems to me that excel is running active or in background and that this is blocking the write range. Just try to close / kill process Excel and try again

Hello,
I understand that you understand another language, I will try to write as specific as possible.

I was reviewing the last thread you wrote me and to solve the excel problem I put the activity “ExcelCloseWorkbook” which apparently worked.

However, the data I have stored is not entirely what I need.

I made a list of the tags that I want to obtain but my question is: In what activity can I add the XML tags so that only this data reaches my excel?

tag values ​​i want to get:

<cbc:ProfileID></cbc:ProfileID>
<cbc:ParentDocumentID></cbc:ParentDocumentID>
<cbc:RegistrationName></cbc:RegistrationName>
<cbc:CompanyID schemeAgencyID="195" schemeID="0" schemeName="31"></cbc:CompanyID>
<cbc:RegistrationName></cbc:RegistrationName>
<cbc:CompanyID></cbc:CompanyID>
<cbc:CompanyID schemeAgencyID="195" schemeID="0" schemeName="31"></cbc:CompanyID>
<cbc:IssueTime></cbc:IssueTime>
<cac:SellersItemIdentification><cbc:ID></cbc:ID></cac:SellersItemIdentification>
<cbc:Description></cbc:Description>
<cbc:BaseQuantity unitCode="94"></cbc:BaseQuantity>
ValTolFac:
<cbc:Note></cbc:Note><cbc:Note>
<cac:PaymentMeans><cbc:ID>2</cbc:ID><cbc:PaymentMeansCode>3</cbc:PaymentMeansCode><cbc:PaymentDueDate></cbc:PaymentDueDate></cac:PaymentMeans>
<cbc:Note></cbc:Note>
<cbc:Percent></cbc:Percent>
<cbc:UUID schemeID="1" schemeName="CUFE-SHA384"></cbc:UUID>

Lector.xaml (15.8 KB)

Document.xlsx (25.8 KB)

@Fabian_DDD

I do feel that a XPath Approach is better for the retrieval

Setting up a NamespaceManager with a Config Datatable:
grafik

for the default namespace with empty prefix “def” is assigne as prefix

the retrieval is configured as another datatable (could also be externalize into an excel)

I did also for a deeper nested element for demo purpose

After all preperation it is iterating over the retrieval config and retrieves the specfied values. et voila:
grafik

So this result can be used and preprocess (e.g. removing path column, dynamic reating another structure…)

I did it as a quick prototype for you and you can finalize.

Open the XML in Chrome or Firefox and activate the Webtools (F12)
with following you can easy get the Xpath: Kopieren means Copy:

Demo XAML here:
Lector_V2.xaml (16.7 KB)

Hello

I am trying to run the project, but from the first run I encounter the following problem:

“Log Message: Object reference not set as an instance of an object.”

I don’t know if the problem only occurs on my computer

I never share a demo xaml without running it sucessfully on my machine.
In such a case the standard procedure is:

  • Debugging
  • inspecting the value of xeXpat…Name variable. if the content is null finding out the root cause for this.

But you have not done any changes on the code base right?

The only change I made was to direct the “Read Text File” activity to my XML.

Now that the error is up, I am trying to change the label like this: xDoc.Root.XPathSelectElement (" cbc: CustomizationID ", NamespaceMGR)

But the error continues.

yes but never with spaces in name
Use “cbc:CustomizationID” for the name