0

Seemingly, libxml2 has only 4 datatypes namely xmlChar, xmlDoc, xmlNodePtr and xml- Node. I want to keep integer and double in the nodes of XML, Do I have to cast them to string each time or Is there any other way to do it without any casting?

bfaskiplar
  • 865
  • 1
  • 7
  • 23

1 Answers1

0

You must cast them to string. XML has no concept of "integet" or "float", it's all text. There are technologies that can layer these concepts on top (like XSD), but not XML itself.

Similarly, when you parse XML and get the content of nodes, you can only get strings that you must convert yourself.

Jason Viers
  • 1,722
  • 12
  • 20
  • Thank you for your answer. But XSD seems to have such things. For instance it can indicate that some specific node should store some specific data type, so Is this something just in order to help programmer figure out which type is stored in a node in XML and cast accordingly? – bfaskiplar Jul 10 '12 at 23:33
  • It is theoretically possible to use XSD for that, it's what SOAP APIs use when transferring over XML. libxml doesn't read the XSD info, though, it operates on the "lower level" of XML directly. – Jason Viers Jul 11 '12 at 02:06