I am making a program where I extract data from an XML file and store it in a listView, the problem is that if it finds more than 1 attribute I have to repeat the value of the element in the next row or leave it blank.
I am attaching my code, in which it works perfectly if it only finds one attribute on the element.
Try
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_nodelist1 As XmlNodeList
Dim m_node As XmlNode
'Creamos el "XML Document"
m_xmld = New XmlDocument()
'Cargamos el archivo
m_xmld.Load(Trim(txtDirectorio.Text))
'Obtenemos la lista de los nodos "name"
m_nodelist = m_xmld.GetElementsByTagName("cfdi:InformacionAduanera")
m_nodelist1 = m_xmld.GetElementsByTagName("cfdi:Concepto")
'Recorrer XML sacar más de un NoIdentificacion
For Each m_node In m_nodelist1
lvNoIdentificacion.Items.Add(m_node.Attributes.GetNamedItem("NoIdentificacion").Value)
Next
'Recorrer XML sacar más de un NumeroPedimento
For Each m_node In m_nodelist
lvNumeroPedimento.Items.Add(m_node.Attributes.GetNamedItem("NumeroPedimento").Value)
Next
'Recorrer los item de la lista
'Verificar que contenga 15 digitos el NumeroPedimento (Length=21 por los espacios en blanco entre grupos de digitos)
'Si el NumeroPedimento no contiene cadena de 15 digitos entonces pintar color Rojo.
Dim i As Integer
For i = 0 To lvNumeroPedimento.Items.Count - 1
If lvNumeroPedimento.Items(i).Text.Length <> 21 Then
lvNumeroPedimento.Items.Item(i).ForeColor = System.Drawing.Color.Red
Else
lvNumeroPedimento.Items.Item(i).ForeColor = System.Drawing.Color.Black
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
The XML is structured as follows
<cfdi:Concepto ClaveProdServ="43223300" NoIdentificacion="AX101100" Cantidad="4" ClaveUnidad="KT" Unidad="kit" Descripcion="Kit Separador de Fibra en campo P/6 Fibras" ValorUnitario="612.00" Importe="2448.00" Descuento="678.34">
<cfdi:Impuestos>
<cfdi:Traslados>
<cfdi:Traslado Base="1769.66" Impuesto="002" TipoFactor="Tasa" TasaOCuota="0.160000" Importe="283.15" />
</cfdi:Traslados>
</cfdi:Impuestos>
<cfdi:InformacionAduanera NumeroPedimento="XX XX 38XX 4XX1254" />
<cfdi:InformacionAduanera NumeroPedimento="XX XX 38XX 400XX41" />
</cfdi:Concepto>
I attach a screenshot to see if you can guide me
Beforehand thank you very much.
With this code I managed to solve my problem, in case someone helps.
The image of how it turned out:![enter image description here](https://i.stack.imgur.com/LQG2M.png)