C++ XML Objects Use: An XML file

Previous Next Usage Home Installation Docs


Now we want an XML to read these from.


Here is a possible XML file that we might have which defines the values for the objects, and also provides for the composite objects (including the pointer):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>


There are lot's of other features of the XML format like the ability to include pieces of XML from other files, but that will be discussed later.

You can see that objects are declared by naming the "type" of the object as the tag, and members are defined by using the name of the member as a tag, followed by the data from the member. For members which are composite (vectors and references), the data for the member is actually an object declaration.

The "types" of the objects just happen to match the name of the type in XML file in this case. A registration mechanism is used (Abstract Factory Pattern), which de couples the name of the class from the string name which represents it. So the actual class could be called "CFoo", but the name in the xml file could be "foo".

You can also see that there is very little difference between a pointer to an object and a vector of pointers, except that you can only have 1 object in the reference.

Previous Next Usage Home Installation Docs

Generated: Wed Apr 5 23:00:20 EST 2006

Copyright (c) 2005; Paul Hamilton; pHamtec P/L.

Use, modification, and distribution is provided free of any limitations.