XML file data extraction
-
Thanks for you help, have decided that I'll script something to change the XML file so that it is correctly formed and therefore I won't need to do the recursive searches(Which are proving tricky because of the dodgy formatting)... I'll post the final code when I get it together.. Thanks again.
Well I got stuck on the recursion so got a script to tidy up the XML file so that it is reasonably well formed.. But now I have an issue getting one element out, <sizedata Size= "VALUE" IGNORE THE REST OF THEM/> here is a fully formed, but shortened XML file: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <Root Type="TRoot"> <Date>15/10/2009 12:30:08</Date> <Folder fullpath="C:\" IsFilesNode="0"> <Name>C:\</Name> <SizeData Size="74609238013" Allocated="72396726232" Wasted="234062016" CDRom="74727184384" Files="116733" Folders="12272" Compression="3"/> </Folder> <Folder fullpath="C:\" IsFilesNode="-1"> <Name>[Files]</Name> <SizeData Size="18745407271" Allocated="18745561088" Wasted="153817" CDRom="18745475072" Files="69" Folders="0" Compression="1"/> </Folder> <Folder fullpath="C:\TEMP_\" IsFilesNode="0"> <Name>TEMP_ALAN</Name> <SizeData Size="15469174140" Allocated="15489126222" Wasted="19886724" CDRom="15478267904" Files="9570" Folders="1832" Compression="1"/> </Folder> <Folder fullpath="C:\TEMP_\mp3\" IsFilesNode="0"> <Name>mp3</Name> <SizeData Size="11504514137" Allocated="11513361814" Wasted="8829863" CDRom="11508457472" Files="4561" Folders="510" Compression="1"/> </Folder> </root> The code I have is below: <pre>Try Dim odoc As New System.Xml.XmlDocument odoc.Load("C:\test\test.xml") Dim oXmlLog As System.Xml.XmlElement Dim text As String = "" For Each oXmlLog In odoc.SelectNodes("Root") Dim node As System.Xml.XmlElement For Each node In oXmlLog.SelectNodes("Folder") Dim fullpath As String = node.Attributes.GetNamedItem("fullpath").Value