--- projects/cms/source/host/c++/XMLFormatter.cpp 2001/03/23 14:07:11 1.5 +++ projects/cms/source/host/c++/XMLFormatter.cpp 2001/03/23 16:38:34 1.6 @@ -2,13 +2,15 @@ XMLFormatter::XMLFormatter( string newHostInfo ){ // std::cout << "DEBUG: " << newHostInfo << "\n"; - xmlData += "<"; - xmlData += newHostInfo; - xmlData += ">"; + if ( newHostInfo != "" ){ - hostInfo = newHostInfo; - // std::cout << "DEBUG: xmldata: " << xmlData << "\n"; - + xmlData += "<"; + xmlData += newHostInfo; + xmlData += ">"; + + hostInfo = newHostInfo; + // std::cout << "DEBUG: xmldata: " << xmlData << "\n"; + } stackPointer = 0; } @@ -47,14 +49,19 @@ void XMLFormatter::closeNest(){ void XMLFormatter::addNest(string nest){ // std::cout << "DEBUG: Adding Nest: " << nest << "\n"; - xmlData += "<"; - xmlData += nest; - xmlData += ">"; - // now add the nest to the stack - stack[stackPointer] = nest; - stackPointer++; - return; + // check it is not empty + if ( nest != "" ){ + xmlData += "<"; + xmlData += nest; + xmlData += ">"; + + // now add the nest to the stack + stack[stackPointer] = nest; + stackPointer++; + } // if + + return; } void XMLFormatter::addElement(string element, string attributes, string value){ @@ -64,25 +71,27 @@ void XMLFormatter::addElement(string element, string a xmlData += " "; xmlData += attributes; xmlData += ">"; - if ( value != "" ){ + xmlData += value; + xmlData += ""; + + return; +} + +void XMLFormatter::addElement(string element, string value){ + // std::cout << "DEBUG: Add Element: " << element << ":" << value << "\n"; + + if (( element != "" ) && ( value != "" )){ + xmlData += "<"; + xmlData += element; + xmlData += ">"; xmlData += value; xmlData += ""; } // if return; -} - -void XMLFormatter::addElement(string element, string value){ - // std::cout << "DEBUG: Add Element: " << element << ":" << value << "\n"; - xmlData += "<"; - xmlData += element; - xmlData += ">"; - xmlData += value; - xmlData += ""; - return; }