Re: [xml] XML typing



Aron Stansvik wrote:
2007/12/28, fabio antonini kaskonetworks it <fabio antonini kaskonetworks it>:
Hi
I'm a XML newbie and I'm facing the following (trivial)
problem.
I have read and implemented the XMLTutorial. Now I want to
use libxml for reading a XML file I have created. The XML
file seems like that

        <command CMD="CMD_TBL_HELP">
                <name>help</name>
                <lmin>4</lmin>
                <maxargs>25</maxargs>
                <rep>1</rep>
                <cmd>do_help</cmd>
                <usage>help - &lt;cli command name&gt; =
|command_name]</usage>
                <shelp>help - Show help information (for
'command')</shelp>
        </command>

The XML file includes both strings and decimal value.
I have no problem to parse the string values (usage or shelp
fields), but
how can I import the decimal fields as "rep" or "maxargs".
When I parse the file their value is always a string. I
would like to import their decimal value.

This is not a libxml2 question, but a general C programming question.
Converting strings to numbers can be done using functions in your
standard C library. Look at the manual pages for strotol() for
instance. What function to use depends on what type of conversion you
want.

I may be mistaken, but would it be still more 'correct' to first use iconv to convert the strings from xmlChar to char and then use the standard conversion functions?


Jason Valenzuela



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]