XML Mapping
If you need to capture an XML, use the following mapping.
Find the File Type for which you will create the mapping and select the "Edit Field Mapping" option.
- Create a new one.
- Within the new mapping, load the mandatory fields
Fill in the 'Source Path' field with any value that allows you to easily identify the mapping (e.g., 'XML').
Select a template. In this case, use an empty template named 'Dummy.'
Finally, complete the fields to be mapped and proceed to save.
When creating the capture process, specify which mapping should be used for the XML by editing the classification task and filling in the 'Source Path of the template to map the captured XML' field with the 'Source Path' name you entered in the mapping.
Define Positions
To extract data from an XML, queries are used in the database. Therefore, to perform the mappings, you must load the exact nomenclature defined by SQL Server.
For example, you need to load the fields "Key" and "Unit" for our "Product" File Type, given the following XML:
<cfdi:Comprobante xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd" LugarExpedicion="97300" MetodoPago="PUE" TipoDeComprobante="I" Total="56550.00" Moneda="MXN" Fecha="2020-01-03T10:36:32" Folio="08" Serie="A" Version="3.3" xmlns:cfdi="http://www.sat.gob.mx/cfd/3">
<cfdi:Conceptos>
<cfdi:Concepto>
<ClaveProdServ>81112005</ClaveProdServ>
<Descripcion>Tetera</Descripcion >
<ClaveUnidad>E48</ClaveUnidad>
</cfdi:Concepto>
<cfdi:Concepto>
<ClaveProdServ>81112006</ClaveProdServ>
<Descripcion>Parlante</Descripcion>
<ClaveUnidad>E47</ClaveUnidad>
</cfdi:Concepto>
</cfdi:Conceptos>
</cfdi:Comprobante>
If you want to retrieve values only from the first concept and load them into fields of your File Type, you should map it as follows:
In the position of your 'Key' field, you would use: (/*:Comprobante/*:Conceptos/*:Concepto/*:ClaveProdServ/text())[1].
Since the value taken is from the XML tag, you reach it through the path /*:Comprobante/*:Conceptos/*:Concepto/ClaveProdServ. Then, indicate that you want to take the text from the tag using the function text().
To ensure you only retrieve the first occurrence, enclose the expression in parentheses and specify the row with square brackets [1].
Now, suppose our XML looks as follows:
<cfdi:Comprobante xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd" LugarExpedicion="97300" MetodoPago="PUE" TipoDeComprobante="I" Total="56550.00" Moneda="MXN" Fecha="2020-01-03T10:36:32" Folio="08" Serie="A" Version="3.3" xmlns:cfdi="http://www.sat.gob.mx/cfd/3">
<cfdi:Conceptos>
<cfdi:Concepto ClaveProdServ=”81112005” Descripcion=”Parlante” ClaveUnidad=”E48” />
<cfdi:Concepto ClaveProdServ=”81112006” Descripcion=”Tetera” ClaveUnidad=”E47” />
</cfdi:Conceptos>
</cfdi:Comprobante>
As you can see, the values are presented as attributes and not as text within the tag.
To retrieve the attribute of the first occurrence of 'ClaveProdServ,' you should use the following nomenclature:
(/*:Comprobante/*:Conceptos/*:Concepto/@ClaveProdServ)[1].
This is similar to the previous example, but once you reach the tag, indicate the attribute you want to retrieve with '@' followed by the attribute name.
Again, enclose the position in parentheses and specify the occurrence to retrieve with square brackets."
Grids
If you wish to capture a set of occurrences, you should use a grid.
To do this, map it as follows, using the same XML.
In the position, specify the path to the repeating tag, followed by the columns separated by commas (',').
As before, if the value is an attribute, prepend '@' to its name; if it's a tag, use the tag name followed by '/text()'. All of this should be enclosed in parentheses. In both cases, indicate the occurrence with [1].
Example:
- Attribute: @ClaveUnidad[1]
- Text from the Tag: (ClaveUnidad/text())[1]
Additionally, in these cases, concatenate the column name in Netcontent with '|'. As shown in the image, if you want '@Descripcion[1]' to be loaded into the 'Apellido' column, you would use: @Descripcion[1]|Apellido, and for 'ClaveUnidad' in 'Nombre': @ClaveUnidad[1]|Nombre
Obtain Email Data
When processing files received via email, you can extract values directly from the email.
All email values are uploaded in XML format, so you can apply the same mapping techniques discussed in this document. However, in the classification task of the capture process, fill in the "Source Path of the template to map the Email XML" field with the root of the mapping created.
The XML structure of the emails is always as follows:
<mail>
<from><a href = 'mailto:rodrigo.maclean@bizitglobal.com'>Rodrigo Mac Lean</a></from>
<subject>Fwd: Test captura emial</subject>
<sentdate>07-Apr-22 2:50:42 PM</sentdate>
<body>Este es el Mensaje del mail</body>
</mail>
- To obtain the email from the from tag, use:
(//*:mail/from/a/@href)[1]
- To get the mail:
(//*:mail/from/a/text())[1]
- To retrieve the subject:
(//*:mail/subject/text())[1]
- To obtain the sent date:
(//*:mail/sentdate/text())[1]
- To get the body::
(//*:mail/body/text())[1]
Obtain Data from Barcodes or QR Codes
For capturing barcodes, Netcontent retrieves two values using the reserved keywords Data and BC_TEXT.
- Data is the value of the barcode.
- BC_TEXT is the raw content as it appears after being read from the file.
Example:
- Data: 44fe5c3037e4b44d723c272818809cd9d723028a
- BC_TEXT:
{"state":null,"BarCodes":[{"Page":1,"Type":"CODE_128","Data":"44fe5c3037e4b44d723c272818809cd9d723028a","Points":[{"X":"643.5","Y":"534.0"},{"X":"1626.5","Y":"534.0"}]}]}
QR codes return a URL from which values can be obtained in JSON format.
For Example: https://www.afip.gov.ar/fe/qr/?p=eyJ2ZXIiOjEsImZlY2hhIjoiMjAyMS0wNC0yMCIsImN1aXQiOjMwNjg0OTY4MjE4LCJwdG9WdGEiOjcsInRpcG9DbXAiOjAsIm5yb0NtcCI6NDA1LCJpbXBvcnRlIjozMzYzODEuMjEsIm1vbmVkYSI6IlBFUyIsImN0eiI6MSwidGlwb0RvY1JlYyI6MjAxLCJucm9Eb2NSZWMiOjMwNjE4NzA1NjcyICAgICAgICwidGlwb0NvZEF1dCI6IkUiLCJjb2RBdXQiOiI3MTE2ODkzNTMzOTI3MCJ9
To instruct the Netcontent capture process to take the hash of the "p" parameter, edit the "Parameter to find the Json of the QrCode" field in the classification task.
The content of the hash taken from the selected parameter, after decoding, contains the JSON object.
Following the example:
{"ver":1,"fecha":"2021-04-20","cuit":30684968218,"ptoVta":7,"tipoCmp":0,"nroCmp":405,"importe":336381.21,"moneda":"PES","ctz":1,"tipoDocRec":201,"nroDocRec":30618705672 ,"tipoCodAut":"E","codAut":"71168935339270"}
With this object you can fill the fields of the File given a mapping.
QR_TEXT hosts all the Json formed with the coordinates, which is then analyzed to obtain individual mapping data:
{"state":null,"BarCodes":[{"Page":1,"Type":"QR_CODE","Data":"https://www.afip.gob.ar/fe/qr/?p=eyJ2ZXIiOjEsImZlY2hhIjoiMjAyMS0wNC0yMCIsImN1aXQiOjMwNjg0OTY4MjE4LCJwdG9WdGEiOjcsInRpcG9DbXAiOjAsIm5yb0NtcCI6NDA1LCJpbXBvcnRlIjozMzYzODEuMjEsIm1vbmVkYSI6IlBFUyIsImN0eiI6MSwidGlwb0RvY1JlYyI6MjAxLCJucm9Eb2NSZWMiOjMwNjE4NzA1NjcyICAgICAgICwidGlwb0NvZEF1dCI6IkUiLCJjb2RBdXQiOiI3MTE2ODkzNTMzOTI3MCJ9","Points":[{"X":"126.5","Y":"3360.0"},{"X":"126.5","Y":"2952.0"},{"X":"534.0","Y":"2952.0"},{"X":"514.0","Y":"3340.0"}]}]}
Note:
In the same mapping you can combine tags from the ABBYY tree, json from QR or BAR Codes, capture xml and email since Netcontent processes everything and then loads the values of the File with the capture.
It is important to keep in mind that if we have different mappings for each type of capture and there are fields that are used in more than one mapping, the field will remain with the value taken by the last replacement where the order will be captured by ABBYY, QR/ bar codes, xml and finally mail.
MSSQL XML Query Example: https://www.youtube.com/watch?v=JscynQHUs5U
Created with the Personal Edition of HelpNDoc: Step-by-Step Guide: How to Turn Your Word Document into an eBook