📄 main.cc
字号:
// -*- C++ -*-/* main.cc * * Copyright (C) 2002 The libxml++ development team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <fstream>#include <iostream>#include "myparser.h"intmain(int argc, char* argv[]){ std::string filepath; if(argc > 1 ) filepath = argv[1]; //Allow the user to specify a different XML file to parse. else filepath = "example.xml"; // Parse the entire document in one go: try { MySaxParser parser; parser.set_substitute_entities(true); // parser.parse_file(filepath); } catch(const xmlpp::exception& ex) { std::cout << "libxml++ exception: " << ex.what() << std::endl; } // Demonstrate incremental parsing, sometimes useful for network connections: { //std::cout << "Incremental SAX Parser:" << std:endl; std::ifstream is(filepath.c_str()); char buffer[64]; MySaxParser parser; do { is.read(buffer, 63); std::string input(buffer, is.gcount()); parser.parse_chunk(input); } while(is); parser.finish_chunk_parsing(); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -