本文整理汇总了C++中TiXmlDeclaration::Parse方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlDeclaration::Parse方法的具体用法?C++ TiXmlDeclaration::Parse怎么用?C++ TiXmlDeclaration::Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlDeclaration
的用法示例。
在下文中一共展示了TiXmlDeclaration::Parse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateResponXML
void CCardProcess::CreateResponXML(int nID, const char *szResult, char *RetXML)
{
TiXmlDocument *XmlDoc;
TiXmlElement *RootElement;
TiXmlElement *Segment;
TiXmlDeclaration HeadDec;
TiXmlPrinter Printer;
// 创建XML文档
XmlDoc = new TiXmlDocument();
// 增加XML的头部说明
HeadDec.Parse("<?xml version=\"1.0\" encoding=\"gb2312\" ?>", 0, TIXML_ENCODING_UNKNOWN);
XmlDoc->LinkEndChild(&HeadDec);
RootElement = new TiXmlElement("CardProcess");
Segment = new TiXmlElement("ReturnInfo");
Segment->SetAttribute("ID", nID);
Segment->SetAttribute("Desc", szResult);
RootElement->LinkEndChild(Segment);
XmlDoc->LinkEndChild(RootElement);
XmlDoc->Accept(&Printer);
strcpy(RetXML, Printer.CStr());
}
示例2: CreateHISReaderXML
void CreateHISReaderXML(const std::map<int, HISReader> &mapReader, char *strHISReader)
{
TiXmlDocument *XmlDoc = NULL;
TiXmlElement *RootElement = NULL;
TiXmlElement *Segment = NULL;
TiXmlElement *Column = NULL;
TiXmlDeclaration HeadDec;
TiXmlPrinter Printer;
// 创建XML文档
XmlDoc = new TiXmlDocument();
// 增加XML的头部说明
HeadDec.Parse("<?xml version=\"1.0\" encoding=\"gb2312\" ?>", 0, TIXML_ENCODING_UNKNOWN);
XmlDoc->LinkEndChild(&HeadDec);
RootElement = new TiXmlElement("SEGMENTS");
RootElement->SetAttribute("PROGRAMID", "001");
Segment = new TiXmlElement("SEGMENT");
Segment->SetAttribute("ID", 2);
std::map<int, HISReader>::const_iterator iter = mapReader.begin();
for (; iter != mapReader.end(); ++iter)
{
const HISReader &stHIS = iter->second;
Column = new TiXmlElement("COLUMN");
Column->SetAttribute("ID", iter->first);
Column->SetAttribute("DESC", stHIS.strDesc.c_str());
Column->SetAttribute("VALUE", stHIS.strValue.c_str());
Segment->LinkEndChild(Column);
}
RootElement->LinkEndChild(Segment);
XmlDoc->LinkEndChild(RootElement);
XmlDoc->Accept(&Printer);
strcpy(strHISReader, Printer.CStr());
}
示例3: _FormatWrite
static int _FormatWrite(std::map<int, std::string> &mapAll, char *strFMTWrite)
{
TiXmlDocument *XmlDoc;
TiXmlElement *RootElement;
TiXmlElement *Segment;
TiXmlElement *Colum;
TiXmlDeclaration HeadDec;
TiXmlPrinter Printer;
// 增加XML的头部说明
XmlDoc = new TiXmlDocument();
HeadDec.Parse("<?xml version=\"1.0\" encoding=\"gb2312\" ?>", 0, TIXML_ENCODING_UNKNOWN);
XmlDoc->LinkEndChild(&HeadDec);
RootElement = new TiXmlElement("SEGMENTS");
RootElement->SetAttribute("PROGRAMID", "001");
Segment = new TiXmlElement("SEGMENT");
Segment->SetAttribute("ID", 2);
std::map<int, std::string>::iterator iter = mapAll.begin();
for (; iter != mapAll.end(); ++iter)
{
Colum = new TiXmlElement("COLUMN");
Colum->SetAttribute("ID", iter->first);
Colum->SetAttribute("VALUE", iter->second.c_str());
Segment->LinkEndChild(Colum);
}
RootElement->LinkEndChild(Segment);
XmlDoc->LinkEndChild(RootElement);
XmlDoc->Accept(&Printer);
strcpy(strFMTWrite, Printer.CStr());
return 0;
}
示例4: main
int main()
{
//
// We start with the 'demoStart' todo list. Process it. And
// should hopefully end up with the todo list as illustrated.
//
const char* demoStart =
"<?xml version=\"1.0\" standalone='no' >\n"
"<!-- Our to do list data -->"
"<ToDo>\n"
"<!-- Do I need a secure PDA? -->\n"
"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
"<Item priority=\"2\" distance='none'> Do bills </Item>"
"<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>"
"</ToDo>";
{
#ifdef TIXML_USE_STL
// What the todo list should look like after processing.
// In stream (no formatting) representation.
const char* demoEnd =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<!-- Our to do list data -->"
"<ToDo>"
"<!-- Do I need a secure PDA? -->"
"<Item priority=\"2\" distance=\"close\">Go to the"
"<bold>Toy store!"
"</bold>"
"</Item>"
"<Item priority=\"1\" distance=\"far\">Talk to:"
"<Meeting where=\"School\">"
"<Attendee name=\"Marple\" position=\"teacher\" />"
"<Attendee name=\"Voel\" position=\"counselor\" />"
"</Meeting>"
"<Meeting where=\"Lunch\" />"
"</Item>"
"<Item priority=\"2\" distance=\"here\">Do bills"
"</Item>"
"</ToDo>";
#endif
// The example parses from the character string (above):
#if defined( WIN32 ) && defined( TUNE )
_CrtMemCheckpoint( &startMemState );
#endif
{
// Write to a file and read it back, to check file I/O.
TiXmlDocument doc( "demotest.xml" );
doc.Parse( demoStart );
if ( doc.Error() )
{
printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
exit( 1 );
}
doc.SaveFile();
}
TiXmlDocument doc( "demotest.xml" );
bool loadOkay = doc.LoadFile();
if ( !loadOkay )
{
printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
exit( 1 );
}
printf( "** Demo doc read from disk: ** \n\n" );
printf( "** Printing via doc.Print **\n" );
doc.Print( stdout );
{
printf( "** Printing via TiXmlPrinter **\n" );
TiXmlPrinter printer;
doc.Accept( &printer );
fprintf( stdout, "%s", printer.CStr() );
}
#ifdef TIXML_USE_STL
{
printf( "** Printing via operator<< **\n" );
std::cout << doc;
}
#endif
TiXmlNode* node = 0;
TiXmlElement* todoElement = 0;
TiXmlElement* itemElement = 0;
// --------------------------------------------------------
// An example of changing existing attributes, and removing
// an element from the document.
// --------------------------------------------------------
// Get the "ToDo" element.
// It is a child of the document, and can be selected by name.
node = doc.FirstChild( "ToDo" );
//.........这里部分代码省略.........
示例5: main
int main()
{
//
// We start with the 'demoStart' todo list. Process it. And
// should hopefully end up with the todo list as illustrated.
//
const char* demoStart =
"<?xml version=\"1.0\" standalone='no' >\n"
"<!-- Our to do list data -->"
"<ToDo>\n"
"<!-- Do I need a secure PDA? -->\n"
"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
"<Item priority=\"2\" distance='none'> Do bills </Item>"
"<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>"
"</ToDo>";
#ifdef TIXML_USE_STL
/* What the todo list should look like after processing.
In stream (no formatting) representation. */
const char* demoEnd =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<!-- Our to do list data -->"
"<ToDo>"
"<!-- Do I need a secure PDA? -->"
"<Item priority=\"2\" distance=\"close\">Go to the"
"<bold>Toy store!"
"</bold>"
"</Item>"
"<Item priority=\"1\" distance=\"far\">Talk to:"
"<Meeting where=\"School\">"
"<Attendee name=\"Marple\" position=\"teacher\" />"
"<Attendee name=\"Voel\" position=\"counselor\" />"
"</Meeting>"
"<Meeting where=\"Lunch\" />"
"</Item>"
"<Item priority=\"2\" distance=\"here\">Do bills"
"</Item>"
"</ToDo>";
#endif
// The example parses from the character string (above):
#if defined( WIN32 ) && defined( TUNE )
QueryPerformanceCounter( (LARGE_INTEGER*) (&start) );
#endif
{
// Write to a file and read it back, to check file I/O.
TiXmlDocument doc( "demotest.xml" );
doc.Parse( demoStart );
if ( doc.Error() )
{
printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
exit( 1 );
}
doc.SaveFile();
}
TiXmlDocument doc( "demotest.xml" );
bool loadOkay = doc.LoadFile();
if ( !loadOkay )
{
printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
exit( 1 );
}
printf( "** Demo doc read from disk: ** \n\n" );
doc.Print( stdout );
TiXmlNode* node = 0;
TiXmlElement* todoElement = 0;
TiXmlElement* itemElement = 0;
// --------------------------------------------------------
// An example of changing existing attributes, and removing
// an element from the document.
// --------------------------------------------------------
// Get the "ToDo" element.
// It is a child of the document, and can be selected by name.
node = doc.FirstChild( "ToDo" );
assert( node );
todoElement = node->ToElement();
assert( todoElement );
// Going to the toy store is now our second priority...
// So set the "priority" attribute of the first item in the list.
node = todoElement->FirstChildElement(); // This skips the "PDA" comment.
assert( node );
itemElement = node->ToElement();
assert( itemElement );
itemElement->SetAttribute( "priority", 2 );
// Change the distance to "doing bills" from
// "none" to "here". It's the next sibling element.
itemElement = itemElement->NextSiblingElement();
assert( itemElement );
//.........这里部分代码省略.........