Hi Adrian, Adrian Schubert <[EMAIL PROTECTED]> writes:
> Question (2): > The data I need to extract can be strings, short/long integers, or > single/double floats. > All the code examples I've seen so far have treated elements as strings. > What's the most elegant way to read in values of various types? > Do I really have to do after-the-fact conversions, for example using > atoi()? That seems a bit odd. Yes, it is. There is a technique called XML Data Binding which boils down to having a tool automatically generate the code that does such extractions (and insertions, if you need to write XML). Such a tool would need a formal description of your XML vocabulary so that it knows which element is short and which is double, etc. Most of Data Binding tools use XML Schema as the specification language. So if you already have XML Schema for your vocabulary then this can be an elegant alternative to DOM or SAX. One open-source XML Data Binding tool for C++ is CodeSynthesis XSD (I am involved in its development): http://www.codesynthesis.com/products/xsd/ For a quick introduction to the concept, check the following two "Hello World" examples. The first describes an in-memory approach, similar to DOM and the second -- event-driven, similar to SAX: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#2 http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#2 HTH, Boris
