Back to index

Parsing any XML that you retrieve from the FleetManagerApi webservice

For any XML the FleetManagerApi returns, our intention is that the documented childnodes of an element are going to be there and if the documentation suggests that there is only one child node with a given name then you can rely on having only one child note with that name.

On the other hand do not rely on the documented nodes to be the only child nodes for any elements. E.g. let us say that you need to parse this XML:

<root>
  <child1>anyvalue</child1>
</root>

Parse this XML in a way that if the XML gets 2 new child elements (see example below), your application can still find child1 in the new structure without any code change.

Example for new child elements:

  <root>
    <child0>added_value1</child0>
    <child1>anyvalue</child1>
    <child2>added_value2</child2>
  </root>

The same applies to attributes as well.

Parsing doubles

When you parse the value of doubles please be prepared that doubles can be also represented in exponential form:
1E-10
In C# we recommend using double.Parse() or double.TryParse() to convert a string into a double.
In Java we recommend Double.parseDouble() to convert a string into a double.