怎样去除xml文件头中的encoding和standalone属性
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLUni.hpp>
#include "DOMTreeErrorReporter.hpp"
#include "DOMPrintFilter.hpp"
#include "DOMPrintErrorHandler.hpp"
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/dom/deprecated/DOMString.hpp>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
static char* gXmlFile = 0;
static bool gDoNamespaces = false;
static bool gDoSchema = false;
static bool gSchemaFullChecking = false;
static bool gDoCreate = false;
static char* goutputfile = 0;
static XMLCh* gOutputEncoding = 0;
static bool gSplitCdataSections = true;
static bool gDiscardDefaultContent = true;
static bool gUseFilter = false;
static bool gFormatPrettyPrint = false;
static bool gWriteBOM = false;
static XercesDOMParser::ValSchemes gValScheme = XercesDOMParser::Val_Auto;
void usage();
void usage()
{
XERCES_STD_QUALIFIER cout << "\nUsage:\n"
" DOMPrint [options] <XML file>\n\n"
"This program invokes the DOM parser, and builds the DOM tree.\n"
"It then asks the DOMWriter to serialize the DOM tree.\n"
"Options:\n"
" -e create entity reference nodes. Default is no expansion.\n"
" -v=xxx Validation scheme [always | never | auto*].\n"
" -n Enable namespace processing. Default is off.\n"
" -s Enable schema processing. Default is off.\n"
" -f Enable full schema constraint checking. Defaults is off.\n"
" -wenc=XXX Use a particular encoding for output. Default is\n"
" the same encoding as the input XML file. UTF-8 if\n"
" input XML file has not XML declaration.\n"
" -wfile=xxx Write to a file instead of stdout.\n"
" -wscs=xxx Enable/Disable split-cdata-sections. Default on\n"
" -wddc=xxx Enable/Disable discard-default-content. Default on\n"
" -wflt=xxx Enable/Disable filtering. Default off\n"
" -wfpp=xxx Enable/Disable format-pretty-print. Default off\n"
" -wbom=xxx Enable/Disable write Byte-Order-Mark Default off\n"
" -? Show this help.\n\n"
" * = Default if not provided explicitly.\n\n"
"The parser has intrinsic support for the following encodings:\n"
" UTF-8, USASCII, ISO8859-1, UTF-16[BL]E, UCS-4[BL]E,\n"
" WINDOWS-1252, IBM1140, IBM037, IBM1047.\n"
<< XERCES_STD_QUALIFIER endl;
}
int main(int argC, char* argV[])
{
int retval = 0;
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException &toCatch)
{
XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n"
<< " Exception message:"
<< StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
return 1;
}
if (argC < 2)
{
usage();
XMLPlatformUtils::Terminate();
return 1;
}
int parmInd;
for (parmInd = 1; parmInd < argC; parmInd++)
{
if (argV[parmInd][0] != '-')
break;
if (!strcmp(argV[parmInd], "-?"))
{
usage();
XMLPlatformUtils::Terminate();
return 2;
}
else if (!strncmp(argV[parmInd], "-v=", 3)
|| !strncmp(argV[parmInd], "-V=", 3))
{
const char* const parm = &argV[parmInd][3];
if (!strcmp(parm, "never"))
gValScheme = XercesDOMParser::Val_Never;
else if (!strcmp(parm, "auto"))
gValScheme = XercesDOMParser::Val_Auto;
else if (!strcmp(parm, "always"))
gValScheme = XercesDOMParser::Val_Always;
else
{
XERCES_STD_QUALIFIER cerr << "Unknown -v= value: " << parm << XERCES_STD_QUALIFIER endl;
XMLPlatformUtils::Terminate();
return 2;
}
}
else if (!strcmp(argV[parmInd], "-n")
|| !strcmp(argV[parmInd], "-N"))
{
gDoNamespaces = true;
}
else if (!strcmp(argV[parmInd], "-s")
|| !strcmp(argV[parmInd], "-S"))
{
gDoSchema = true;
}
else if (!strcmp(argV[parmInd], "-f")
|| !strcmp(argV[parmInd], "-F"))
{
gSchemaFullChecking = true;
}
else if (!strcmp(argV[parmInd], "-e")
|| !strcmp(argV[parmInd], "-E"))
{
gDoCreate = true;
}