Hi Laura,

Laura Lozano <[EMAIL PROTECTED]> writes:

> In the xml documents I've different types like xsd:double, xsd:bool
> that I would like to transform in c++ equivalent types, but how could
> I do it if the  method getNodeValue() return  a type XMLCh?

One way to do this is to use an XML data binding tool that generates
the C++ code to automatically convert between C++ types and XML data.
For example, you can try our open-source CodeSynthesis XSD:

http://www.codesynthesis.com/products/xsd/


Or you can do it manually by first converting XMLCh to char, then
parsing the text to double (e.g., using strtod() or std::istringstream)
or bool (in this case you will have to do parsing yourself). It could
be quite tricky to write such code in a robust manner. For example,
xsd:double always uses '.' as a fraction digits separator. However,
strtod() and std::istringstream use the current locale to determine
which character should be used. If the current locale happened to
use ',' as a a fraction digits separator (which is the case for some
European locales), then your parsing code will fail.

Boris

-- 
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding

Reply via email to