0

I have a simple xml file which I need to read in c++. I am working on Windows so I choose MSXML. And it wouldn't be a problem if not for the way of how data is saved in the xml file. I cannot modify files as I have a lot of them + I can get a lot more in future. So the part that interest me the most in the xml file is:

<data>
    <sample cost="2.000000000000000e+01">1</sample> 
</data>

In the beginning of the xml I have specified a precision of the number and how much digits can be ignored.

So far by doing:

MSXML::IXMLDOMNodeListPtr temp = xmlDoc->selectNodes("data/*");
temp->Getitem(0)->Getxml(); 

gives me whole line as a string also:

temp->Getitem(0)->Gettext();

gives me a number between sections (in this case it is 1) but as a string. I dont know how to get access to a number in <> without manualy getting it from string returned by Getxml().

Getting this numbers manualy from string and converting them to double and int isnt a problem but I want to know if there is a way to directly get access to this numbers in double and int format.

maazza
  • 7,016
  • 15
  • 63
  • 96
  • Is there any schema associated with the XML input where the schema defines the type of an element or attribute value? – Martin Honnen Jul 22 '15 at 14:09
  • @Martin Yes number in the sample node is always double type with precision given in the beginning of the XML and the number in the text node is always integer type. – Paweł Sołtysiak Jul 22 '15 at 15:13
  • MSXML has some property nodeTypedValue https://msdn.microsoft.com/en-us/library/ms762308%28v=vs.85%29.aspx but as far as I remember that only worked with the presence of a schema in a not standardized format. – Martin Honnen Jul 22 '15 at 17:04

0 Answers0