extract data from "dynamic" XML-files
-
Hi, Hi! I’m writing an application that reads XML files that are auto generated form another application called Xapp. My application is supposed to extract certain data from the generated XML files. Lets say that I need to extract the values from a number of caluclations done by Xapp called A and C in the example below.The calculations that aren't measured wont be listed so the files will variate quite much. A won't be present if its not calculated. What is the best and most dynamic way of extracting the data? I found the xmlreader abit to static. Is Xpath the right way? I’m developing in .Net 2.0 (very simplified example ) Calculations A 4.9 B 1.0 C 2.0 Many Thanks /Ibana
-
Hi, Hi! I’m writing an application that reads XML files that are auto generated form another application called Xapp. My application is supposed to extract certain data from the generated XML files. Lets say that I need to extract the values from a number of caluclations done by Xapp called A and C in the example below.The calculations that aren't measured wont be listed so the files will variate quite much. A won't be present if its not calculated. What is the best and most dynamic way of extracting the data? I found the xmlreader abit to static. Is Xpath the right way? I’m developing in .Net 2.0 (very simplified example ) Calculations A 4.9 B 1.0 C 2.0 Many Thanks /Ibana
Personally, I'd build an XML serializable model to read XML into live objects. Then your controlling app can iterate through the graph to get whatever values you need, or you can alter the generated model to do calculations on itself. You can do this with XSD.exe or something like Skeleton Crew[^]. I'm not big on XmlReader or using XPath with XmlDocument, but they are also both reasonable approaches. If you only need the values from one type of node, maybe XPath would be less work. But if you are going to need anything else from your XML, you might want to look at a serializable model.
Try code model generation tools at BoneSoft.com.