int countNodes( TreeNode *root ) {
// Count the nodes in the binary tree to which
// root points, and return the answer.
if ( root == NULL )
return 0; // The tree is empty. It contains no nodes.
else {
int count = 1; // Start by counting the root.
count += countNodes(root->left); // Add the number of nodes
// in the left subtree.
count += countNodes(root->right); // Add the number of nodes
// in the right subtree.
return count; // Return the total.
}
} // end countNodes()
output……..
………..
some thing like this
Your question is unclear, so I guess you want to “output data into an XML file”
Outputing data into a file stream in an XML format could be something like:
Please read the iostream help for more information about the fstream object and its uses:
http://www.cplusplus.com/reference/iostream/
Now, if you want to parse and modify an existing XML, you’ll need an XML parser. You can google those parsers, for example with:
http://www.google.com/search?q=XML+c%2B%2B+parser
Edit:
After reading the comments :
XML is a kind of organized text file. Somewhat like HTML, if is about elements, attributes, and data. For example, this is an XML file content:
For more information, read :
http://www.google.com/search?q=XML