I am making an application to extract data from an xml and through them classify the documents in different folders. I use the XmlNodeList and the XmlElement to extract the attribute from the elements but I do it with two for cycles to achieve that, I would like to know if it is possible to go through the xml structure so that within a single cycle I can obtain the "date" and "rfc" " The application I'm doing in VB.NET
XML structure
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fecha="2017-09-29T10:52:53">
<elemento rfc="XXXXXXXXXXXX" nombre="Nombre">
</elemento>
</root>
My Code so far
Dim doc As XmlDocument
Dim root As XmlNodeList
Dim elemento As XmlNodeList
Dim fecha As XmlElement
Dim rfc As XmlElement
doc = New XmlDocument()
doc.Load("C:\Users\Usuario\Desktop\file.xml")
root = doc.GetElementsByTagName("root")
elemento = doc.GetElementsByTagName("elemento")
For Each fecha In root
strFecha = fecha.GetAttribute("fecha")
Next
For Each rfc In elemento
strRFC = rfc.GetAttribute("rfc")
Next