本文整理汇总了C++中xml_document类的典型用法代码示例。如果您正苦于以下问题:C++ xml_document类的具体用法?C++ xml_document怎么用?C++ xml_document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了xml_document类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ftof_volumes_xml
void ftof_volumes_xml(xml_document& doc, const ForwardTOF& ftof)
{
// start building up the XML document
xml_node geom_node = doc.child("geometry");
if (!geom_node)
{
geom_node = doc.append_child("geometry");
}
xml_node dc_node = geom_node.child("forward_tof");
if (!dc_node)
{
dc_node = geom_node.append_child("forward_tof");
}
xml_node vol_node = dc_node.child("volumes");
if (!vol_node)
{
vol_node = dc_node.append_child("volumes");
}
for (auto k1 : ftof_volumes_map(ftof))
{
xml_node n1 = vol_node.append_child(k1.first.c_str());
for (auto k2 : k1.second)
{
xml_node n2 = n1.append_child(k2.first.c_str());
n2.append_child(node_pcdata).set_value(k2.second.c_str());
}
}
}
开发者ID:theodoregoetz,项目名称:clas12_geometry,代码行数:30,代码来源:ftof_volumes.hpp
示例2: dc_core_params_xml
void dc_core_params_xml(xml_document& doc, const DriftChamber& dc, const string& units="cm")
{
double lconv = length_conversion(units);
// start building up the XML document
xml_node geom_node = doc.child("geometry");
if (!geom_node)
{
geom_node = doc.append_child("geometry");
}
xml_node dc_node = geom_node.child("drift_chamber");
if (!dc_node)
{
dc_node = geom_node.append_child("drift_chamber");
}
xml_node params_node = dc_node.append_child("core_params");
for (int nreg : vector<int>{0, 1, 2})
{
xml_node reg_node = params_node.append_child("region");
reg_node.append_attribute("index") = nreg;
for (int nslyr : vector<int>{0, 1})
{
xml_node slyr_node = reg_node.append_child("superlayer");
slyr_node.append_attribute("index") = nslyr;
slyr_node.append_attribute("wpdist") = dc.sector(0).region(nreg).superlayer(nslyr).wpdist() * lconv;
}
}
}
开发者ID:JeffersonLab,项目名称:clas12_geometry,代码行数:33,代码来源:dc_core_params.hpp
示例3: AppendAttribute
void XmlParse::AppendAttribute(const std::string &NewAttributeName, const std::string &NewAttributeValue,
xml_document<> &doc, xml_node<> *ParentNode)
{
xml_attribute<> *attr = doc.allocate_attribute(doc.allocate_string(NewAttributeName.c_str()),
doc.allocate_string(NewAttributeValue.c_str()));
if (ParentNode)
{
ParentNode->append_attribute(attr);
}
}
开发者ID:ponlee,项目名称:test,代码行数:10,代码来源:XmlParse.cpp
示例4: read_properties_core
void workbook_serializer::read_properties_core(const xml_document &xml)
{
auto &props = workbook_.get_properties();
auto root_node = xml.get_child("cp:coreProperties");
props.excel_base_date = calendar::windows_1900;
if (root_node.has_child("dc:creator"))
{
props.creator = root_node.get_child("dc:creator").get_text();
}
if (root_node.has_child("cp:lastModifiedBy"))
{
props.last_modified_by = root_node.get_child("cp:lastModifiedBy").get_text();
}
if (root_node.has_child("dcterms:created"))
{
std::string created_string = root_node.get_child("dcterms:created").get_text();
props.created = w3cdtf_to_datetime(created_string);
}
if (root_node.has_child("dcterms:modified"))
{
std::string modified_string = root_node.get_child("dcterms:modified").get_text();
props.modified = w3cdtf_to_datetime(modified_string);
}
}
开发者ID:lyntel,项目名称:xlnt,代码行数:26,代码来源:workbook_serializer.cpp
示例5: load_document_copy
static void load_document_copy(xml_document& doc, const char_t* text)
{
xml_document source;
CHECK(source.load(text));
doc.append_copy(source.first_child());
}
开发者ID:antialize,项目名称:pugixml,代码行数:7,代码来源:test_xpath.cpp
示例6: load_concat
static xml_parse_result load_concat(xml_document& doc, const char_t* a, const char_t* b = STR(""), const char_t* c = STR(""))
{
char_t buffer[768];
#ifdef PUGIXML_WCHAR_MODE
wcscpy(buffer, a);
wcscat(buffer, b);
wcscat(buffer, c);
#else
strcpy(buffer, a);
strcat(buffer, b);
strcat(buffer, c);
#endif
return doc.load(buffer, parse_fragment);
}
开发者ID:DamianPrg,项目名称:pugixml,代码行数:16,代码来源:test_parse_doctype.cpp
示例7: LoadXMLFile
bool RawInputParser::LoadXMLFile(xml_document& doc,const string& filePath) const
{
xml_parse_result result = doc.load_file(filePath.c_str());
bool returnResult = false;
if (result)
{
LOG("XML [" << filePath << "] parsed without errors\n");
returnResult = true;
}
else
{
LOG("XML [" << filePath << "] parsed with errors\n");
LOG("Error description: " << result.description() << "\n");
LOG("Error offset: " << result.offset << "\n");
returnResult = false;
}
return returnResult;
}
开发者ID:CSPshala,项目名称:dangerzone,代码行数:21,代码来源:RawInputParser.cpp
示例8: write_xml
/// Initialize the XML DOM structure (leaving .desc unchanged) from the data.
void stream_info_impl::write_xml(xml_document &doc) {
const char *channel_format_strings[] = {"undefined","float32","double64","string","int32","int16","int8","int64"};
xml_node info = doc.append_child("info");
info.append_child("name").append_child(node_pcdata).set_value(name_.c_str());
info.append_child("type").append_child(node_pcdata).set_value(type_.c_str());
info.append_child("channel_count").append_child(node_pcdata).set_value(lexical_cast<string>(channel_count_).c_str());
info.append_child("nominal_srate").append_child(node_pcdata).set_value(lexical_cast<string>(nominal_srate_).c_str());
info.append_child("channel_format").append_child(node_pcdata).set_value(channel_format_strings[channel_format_]);
info.append_child("source_id").append_child(node_pcdata).set_value(source_id_.c_str());
info.append_child("version").append_child(node_pcdata).set_value(lexical_cast<string>(version_/100.0).c_str());
info.append_child("created_at").append_child(node_pcdata).set_value(lexical_cast<string>(created_at_).c_str());
info.append_child("uid").append_child(node_pcdata).set_value(uid_.c_str());
info.append_child("session_id").append_child(node_pcdata).set_value(session_id_.c_str());
info.append_child("hostname").append_child(node_pcdata).set_value(hostname_.c_str());
info.append_child("v4address").append_child(node_pcdata).set_value(v4address_.c_str());
info.append_child("v4data_port").append_child(node_pcdata).set_value(lexical_cast<string>(v4data_port_).c_str());
info.append_child("v4service_port").append_child(node_pcdata).set_value(lexical_cast<string>(v4service_port_).c_str());
info.append_child("v6address").append_child(node_pcdata).set_value(v6address_.c_str());
info.append_child("v6data_port").append_child(node_pcdata).set_value(lexical_cast<string>(v6data_port_).c_str());
info.append_child("v6service_port").append_child(node_pcdata).set_value(lexical_cast<string>(v6service_port_).c_str());
info.append_child("desc");
}
开发者ID:MindContact,项目名称:labstreaminglayer,代码行数:23,代码来源:stream_info_impl.cpp
示例9: toElementText
std::string path::toElementText( xml_document const& _doc )const {
path key_no_attr = *this;
if( key_no_attr.points_to_attr() ) {
path_element& pel = key_no_attr.last();
pel.attr( path_attr() );
}// debug
string pathadd = key_no_attr;
if( pathadd == "domain.features.apic" ) {
pathadd = key_no_attr;
}
element_locator locator( key_no_attr );
_doc.accept( &locator );
xml_element* elem = locator.elementfound();
if( elem != nullptr ) {
xml_node const* ch = elem->first_child();
if( ch == nullptr ) {
return "nullptr";
}
xml_text const* p1 = dynamic_cast<xml_text const*>( ch );
string txt = p1->value();
return txt;
}
return "";
}
开发者ID:rleofield,项目名称:xmlparser,代码行数:38,代码来源:key_path.cpp
示例10: read_shared_strings
bool shared_strings_serializer::read_shared_strings(const xml_document &xml, std::vector<std::string> &strings)
{
strings.clear();
auto root_node = xml.get_child("sst");
auto unique_count = 0;
if (root_node.has_attribute("uniqueCount"))
{
unique_count = std::stoull(root_node.get_attribute("uniqueCount"));
}
for (const auto &si_node : root_node.get_children())
{
if (si_node.get_name() != "si")
{
continue;
}
if (si_node.has_child("t"))
{
strings.push_back(si_node.get_child("t").get_text());
}
else if (si_node.has_child("r"))
{
strings.push_back(si_node.get_child("r").get_child("t").get_text());
}
}
if (unique_count != strings.size())
{
throw std::runtime_error("counts don't match");
}
return true;
}
开发者ID:lyntel,项目名称:xlnt,代码行数:36,代码来源:shared_strings_serializer.cpp
示例11: writeCreateSchemeXml
/**
* @brief WrapperXml::writeXml, metodo para escribir un xml
* @param pRuta, directorio en el que se guardara el documento
* @param pRoot, raiz del documento
* @param pSon, hijo del documento
*/
void WrapperXml::writeCreateSchemeXml(std::string pMsg, xml_document<> &pDocument){
xml_node<>* decl = pDocument.allocate_node(node_declaration);
decl->append_attribute(pDocument.allocate_attribute(VERSION, NUMVERSION));
decl->append_attribute(pDocument.allocate_attribute(ENCODE, TYPEENCODE));
pDocument.append_node(decl);
xml_node<>* root = pDocument.allocate_node(node_element, SCHEME);
pDocument.append_node(root);
std::istringstream pBuffer(pMsg);
std::string subString;
pBuffer >> subString;
xml_node<>* childSN = pDocument.allocate_node(node_element, SCHEMENAME);
childSN->value(strdup(subString.c_str()));
root->append_node(childSN);
pBuffer >> subString;
xml_node<>* childR = pDocument.allocate_node(node_element, RAID);
childR->value(strdup(subString.c_str()));
root->append_node(childR);
while(pBuffer){
pBuffer >> subString;
if(subString==HASH)
break;
else{
xml_node<>* childD = pDocument.allocate_node(node_element, DATA);
xml_node<>* childDT = pDocument.allocate_node(node_element, DATATYPE);
childDT->value(strdup(subString.c_str()));
childD->append_node(childDT);
pBuffer >> subString;
xml_node<>* childDL = pDocument.allocate_node(node_element, DATANAME );
childDL->value(strdup(subString.c_str()));
childD->append_node(childDL);
pBuffer >> subString;
xml_node<>* childDN= pDocument.allocate_node(node_element, DATANAME);
childDN->value(strdup(subString.c_str()));
childD->append_node(childDN);
root->append_node(childD);
}
}
}
开发者ID:DatosII,项目名称:ClienteInmemdb,代码行数:48,代码来源:wrapperxml.cpp
示例12: ftof_panels_parms_xml
void ftof_panels_parms_xml(xml_document& doc, const ForwardTOF& ftof, const string& coordsys="clas", const string& units="cm")
{
double lconv = length_conversion(units);
if (coordsys != "sector" && coordsys != "clas")
{
throw runtime_error(string("can not generate data in ") + coordsys + " coordinates");
}
coordsys_t coord = str2coord(coordsys);
// start building up the XML document
xml_node geom_node = doc.child("geometry");
if (!geom_node)
{
geom_node = doc.append_child("geometry");
}
xml_node ftof_node = geom_node.child("forward_tof");
if (!ftof_node)
{
ftof_node = geom_node.append_child("forward_tof");
}
xml_node panels_node = ftof_node.child("panels_parms");
if (!panels_node)
{
panels_node = ftof_node.append_child("panels_parms");
panels_node.append_attribute("length_units");
panels_node.append_attribute("coordinate_system");
}
panels_node.attribute("length_units") = units.c_str();
panels_node.attribute("coordinate_system") = coordsys.c_str();
for (int sec=0; sec<ftof.sectors().size(); sec++)
{
const forward_tof::Sector& ftof_sector = ftof.sector(sec);
for (int pan=0; pan<ftof_sector.panels().size(); pan++)
{
const forward_tof::Panel& panel = ftof_sector.panel(pan);
xml_node panel_node = panels_node.append_child("panel");
panel_node.append_attribute("sector") = sec;
panel_node.append_attribute("panel") = ftof_sector.panel_name(pan).c_str();
panel_node.append_attribute("npaddles") = int(panel.npaddles());
panel_node.append_attribute("dist2tgt") = panel.dist2tgt() * lconv;
direction_vector<double,3> panel_norm = panel.panel_normal(coord);
panel_node.append_attribute("norm_phi") = panel_norm.phi();
panel_node.append_attribute("norm_theta") = panel_norm.theta();
direction_vector<double,3> paddle_dir = panel.paddle_direction(coord);
panel_node.append_attribute("paddle_phi") = paddle_dir.phi();
panel_node.append_attribute("paddle_theta") = paddle_dir.theta();
panel_node.append_attribute("paddle_width") = panel.paddle_width() * lconv;
panel_node.append_attribute("paddle_thickness") = panel.paddle_thickness() * lconv;
euclid_vector<double,3> paddle_extent = panel.paddle_extent(COORDSYS::SECTOR);
panel_node.append_attribute("paddle_extent_x") = paddle_extent.x() * lconv;
panel_node.append_attribute("paddle_extent_z") = paddle_extent.z() * lconv;
xml_node center_node = panel_node.append_child("paddle_centers");
vector<xml_node> paddle_centers_node;
paddle_centers_node.push_back(center_node.append_child("x"));
paddle_centers_node.push_back(center_node.append_child("y"));
paddle_centers_node.push_back(center_node.append_child("z"));
vector<stringstream> centers(3);
for (auto cntr : panel.paddle_centers(coord))
{
centers[0] << " " << cntr.x() * lconv;
centers[1] << " " << cntr.y() * lconv;
centers[2] << " " << cntr.z() * lconv;
}
for (int i=0; i<paddle_centers_node.size(); i++)
{
paddle_centers_node[i].append_child(pugi::node_pcdata).set_value(
centers[i].str().erase(0,1).c_str());
}
xml_node length_node = panel_node.append_child("paddle_lengths");
stringstream lengths;
for (auto lngth : panel.paddle_lengths())
{
lengths << " " << lngth;
}
length_node.append_child(pugi::node_pcdata).set_value(
lengths.str().erase(0,1).c_str());
}
}
}
开发者ID:JeffersonLab,项目名称:clas12_geometry,代码行数:93,代码来源:ftof_panels_parms.hpp
示例13: loadEnvironment
void ProjectManager::loadEnvironment(xml_document<> &doc)
{
objects.clear();
cout << "loading environment..." << "\n" << flush;
xml_node<> *profile = doc.first_node()->first_node("profile");
xml_node<> *user = profile->first_node("user");
xml_node<> *objecties = profile->first_node("object");
//read x y z h p r from user block and place object there
cout << "obtained variables..." << "\n" << flush;
//look at obj nodes, then check the doc for the location, then import and position at the correct location
string path = projectDir + "\\data\\obj";
//string filename = objecties->first_node("resourceName")->value();
cout << "projdir: " << projectDir << "\n" << flush;
vector<string> pathv;
vector<string> filenamev;
vector<float> objx;
vector<float> objy;
vector<float> objz;
vector<float> objh;
vector<float> objp;
vector<float> objr;
vector<float> objscale;
vector<char *> objname;
//filenamev.push_back(filename);
xml_node<> *userlocation = user->first_node("startingLocation");
if (userlocation != 0)
{
float x = atof(userlocation->first_node("x")->value());
float y = atof(userlocation->first_node("y")->value());
float z = atof(userlocation->first_node("z")->value());
float h = atof(userlocation->first_node("heading")->value());
float p = atof(userlocation->first_node("pitch")->value());
float r = atof(userlocation->first_node("roll")->value());
char *name = user->first_node("name")->value();
objx.push_back(x);
objy.push_back(y+3.3); //for mrbody this should be y+3
objz.push_back(z);
objh.push_back(h);
objp.push_back(p+180); //for mrbody this should be p-12
objr.push_back(r);
objscale.push_back(4); //for mrbody this should be 4
objname.push_back(name);
//string filename = "MrBodyWithHands.obj";
string filename = "batman.obj";
filenamev.push_back(filename);
string pathy = PATH+"Kosmos\\data\\obj";
pathv.push_back(pathy);
//Import::import("cello.obj", x, y, z, h, p, r, "C:\\aszgard5\\szg\\projects\\Kosmos\\data\\obj");
}
while(objecties != 0)
{
cout << "loading object..." << "\n" << flush;
//filename = "";
// get xyzhpr and import object
string filename = objecties->first_node("resourceName")->value();
filenamev.push_back(filename);
pathv.push_back(path);
/*int length = filename.length();
if (filename[length-1] == 'j' && filename[length-2] == 'b' && filename[length-3] == 'o')
{
cout << "wth file is obj " << "\n" << flush;
}*/
float x = atof(objecties->first_node("x")->value());
float y = atof(objecties->first_node("y")->value());
float z = atof(objecties->first_node("z")->value());
float h = atof(objecties->first_node("heading")->value());
float p = atof(objecties->first_node("pitch")->value());
float r = atof(objecties->first_node("roll")->value());
float s = atof(objecties->first_node("scale")->value());
char *name = objecties->first_node("name")->value();
objx.push_back(x);
objy.push_back(y);
objz.push_back(z);
objh.push_back(h);
objp.push_back(p);
objr.push_back(r);
objscale.push_back(s);
objname.push_back(name);
/*
<resourceName>cello.obj</resourceName>
<x>0</x>
<y>4</y>
<z>-4</z>
<heading>0</heading>
<pitch>0</pitch>
<roll>0</roll>
*/
objecties = objecties->next_sibling();
//.........这里部分代码省略.........
开发者ID:KosmosSIDE,项目名称:Kosmos,代码行数:101,代码来源:ProjectManager.cpp
示例14: read_xml
/// Read & assign the object's fields from an XML DOM structure.
void stream_info_impl::read_xml(xml_document &doc) {
try {
xml_node info = doc.child("info");
// name
name_ = info.child_value("name");
if (name_.empty())
throw std::runtime_error("Received a stream info with empty <name> field.");
// type
type_ = info.child_value("type");
// channel_count
channel_count_ = lexical_cast<int>(info.child_value("channel_count"));
if (channel_count_ < 0)
throw std::runtime_error("The channel count of the given stream info is smaller than 0.");
// nominal_srate
nominal_srate_ = lexical_cast<double>(info.child_value("nominal_srate"));
if (nominal_srate_ < 0.0)
throw std::runtime_error("The sampling rate of the given stream info is negative.");
// channel_format
channel_format_ = cf_undefined;
string fmt(info.child_value("channel_format"));
if (fmt == "float32")
channel_format_ = cf_float32;
if (fmt == "double64")
channel_format_ = cf_double64;
if (fmt == "string")
channel_format_ = cf_string;
if (fmt == "int32")
channel_format_ = cf_int32;
if (fmt == "int16")
channel_format_ = cf_int16;
if (fmt == "int8")
channel_format_ = cf_int8;
if (fmt == "int64")
channel_format_ = cf_int64;
// source_id
source_id_ = info.child_value("source_id");
// version
version_ = (int)(lexical_cast<double>(info.child_value("version"))*100.0);
if (version_ <= 0)
throw std::runtime_error("The version of the given stream info is invalid.");
// created_at
created_at_ = lexical_cast<double>(info.child_value("created_at"));
// uid
uid_ = info.child_value("uid");
if (uid_.empty())
throw std::runtime_error("The UID of the given stream info is empty.");
// session_id
session_id_ = info.child_value("session_id");
// hostname
hostname_ = info.child_value("hostname");
// address
v4address_ = info.child_value("v4address");
// data_port
v4data_port_ = lexical_cast<int>(info.child_value("v4data_port"));
// service_port
v4service_port_ = lexical_cast<int>(info.child_value("v4service_port"));
// address
v6address_ = info.child_value("v6address");
// data_port
v6data_port_ = lexical_cast<int>(info.child_value("v6data_port"));
// service_port
v6service_port_ = lexical_cast<int>(info.child_value("v6service_port"));
} catch(std::exception &e) {
// reset the stream info to blank state
*this = stream_info_impl();
name_ = (string("(invalid: ") += e.what()) += ")";
}
}
开发者ID:MindContact,项目名称:labstreaminglayer,代码行数:69,代码来源:stream_info_impl.cpp
示例15:
//!
//! I would like to thank Arseny Kapoulkine for his work on <a href="http://code.google.com/p/pugixml">pugixml</a>,
//! which was an inspiration for this project.
//! Additional thanks go to Kristen Wegner for creating <a href="http://www.codeproject.com/soap/pugxml.asp">pugxml</a>,
//! from which pugixml was derived.
//! Janusz Wohlfeil kindly ran RapidXml speed tests on hardware that I did not have access to,
//! allowing me to expand performance comparison table.
//!
//! \section two_minute_tutorial Two Minute Tutorial
//!
//! \subsection parsing Parsing
//!
//! The following code causes RapidXml to parse a zero-terminated string named <c>text</c>:
//! \verbatim
using namespace rapidxml;
xml_document<> doc; // character type defaults to char
doc.parse<0>(text); // 0 means default parse flags
\endverbatim
//! <c>doc</c> object is now a root of DOM tree containing representation of the parsed XML.
//! Because all RapidXml interface is contained inside namespace <c>rapidxml</c>,
//! users must either bring contents of this namespace into scope, or fully qualify all the names.
//! Class xml_document represents a root of the DOM hierarchy.
//! By means of public inheritance, it is also an xml_node and a memory_pool.
//! Template parameter of xml_document::parse() function is used to specify parsing flags,
//! with which you can fine-tune behaviour of the parser.
//! Note that flags must be a compile-time constant.
//!
//! \subsection accessing_dom_tree Accessing The DOM Tree
//!
//! To access the DOM tree, use methods of xml_node and xml_attribute classes:
//! \verbatim
开发者ID:smanders,项目名称:rapidxml,代码行数:31,代码来源:manual-for-doxygen.hpp
示例16: loadSRSML
void loadSRSML()
{
cout << "parsing srsml..." << endl;
// Read the xml file into a vector
ifstream theFile ("gastrectomy.xml");
vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
buffer.push_back('\0');
// Parse the buffer using the xml file parsing library into doc
doc.parse<0>(&buffer[0]);
// Find our root node
cout << "parsing a root element" << endl;
root_node = doc.first_node("srsml");
int size = strlen((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value());
int size2 = strlen((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value());
// variables for malloc
elements=(char*) malloc(size+1);
elements2=(char*) malloc(size2+1);
strcpy ((char*)elements,(char*)((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value()));
strcpy ((char*)elements2,(char*)((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value()));
// variables for string
str_elements.assign((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value());
str_elements2.assign((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value());
// Iterate over the vessels
if (root_node){
cout << "if there is a root element" << endl;
for (xml_node<> * models_node = root_node->first_node("models"); models_node!=NULL; models_node = models_node->next_sibling())
{
cout << "here is in the model for loop" << endl;
for (xml_node<> * vessels_node = models_node->first_node("vessels"); vessels_node!=NULL; vessels_node = vessels_node->next_sibling())
{
cout << "here is in the vessels for loop" << endl;
printf("I have visited in. ");//,
// Interate over the beers
cout << "here is before the inner for loop" << endl;
for(xml_node<> * vessel_node = vessels_node->first_node("vessel"); vessel_node; vessel_node = vessel_node->next_sibling())
{
printf("On, I tried their %s which is a %s. ",
vessel_node->first_attribute("name")->value(),
vessel_node->first_attribute("type")->value());
}
cout << endl;
}
}
}
}
开发者ID:sunghee,项目名称:SRSdemo-dev,代码行数:53,代码来源:SRSdemo-dev.cpp
示例17: add_to_toc
void add_to_toc(int level, xml_node<char> *title, xml_attribute<char> *id, bool not_numbered)
{
char *style_class;
char *fulltitle = doc.allocate_string(0, title->value_size() + 100);
if (level == 0)
{
style_class = "toc1";
if (not_numbered)
{
sprintf(fulltitle, title->value());
}
else
{
sprintf(fulltitle, "%i. %s", ++numbering[0], title->value());
numbering[1] = 0;
numbering[2] = 0;
}
}
else if (level == 1)
{
style_class = "toc2";
if (not_numbered)
{
sprintf(fulltitle, title->value());
}
else
{
sprintf(fulltitle, "%i.%i %s", numbering[0], ++numbering[1], title->value());
numbering[2] = 0;
}
}
else if (level == 2)
{
style_class = "toc3";
if (not_numbered)
{
sprintf(fulltitle, title->value());
}
else
{
sprintf(fulltitle, "%i.%i.%i %s", numbering[0], numbering[1], ++numbering[2], title->value());
}
}
else
throw std::exception("Invalid TOC level");
xml_node<char> *tocentry = doc.allocate_node(node_element, "a", fulltitle);
char *link = doc.allocate_string(0, id->value_size() + 1);
memcpy(link + 1, id->value(), id->value_size());
link[0] = '#';
tocentry->append_attribute(doc.allocate_attribute("href", link, 0, id->value_size() + 1));
tocentry->append_attribute(doc.allocate_attribute("class", style_class));
toc.append_node(tocentry);
toc.append_node(doc.allocate_node(node_element, "br"));
xml_node<char> *title_data = title->first_node();
if (title_data)
title->remove_node(title_data);
title->value(fulltitle);
}
开发者ID:timniederhausen,项目名称:rapidxml,代码行数:58,代码来源:postprocessor.cpp
示例18: parse
XmlNodeRef XmlParserImp::parse(char* buffer, int bufLen, const char* rootNodeName, behaviac::string& errorString, bool isFinal)
{
BEHAVIAC_UNUSED_VAR(bufLen);
BEHAVIAC_UNUSED_VAR(errorString);
BEHAVIAC_UNUSED_VAR(isFinal);
m_parser.parse<0>(buffer);
xml_node<>* xmlnode = m_parser.first_node(rootNodeName);
XmlNodeRef node = cloneXmlNodeFrom(xmlnode);
return node;
}
开发者ID:ag6ag,项目名称:behaviac,代码行数:14,代码来源:xmlparser.cpp
示例19: load_bounds
void osm_loader::load_bounds()
{
xml_node *root = doc_.first_node("osm");
if (root == NULL)
return;
string str = root->first_node("bound")->first_attribute("box")->value();
vector<string> strs;
boost::split(strs, str, boost::is_any_of(","));
mins.x = atof(strs[0].c_str());
mins.y = atof(strs[1].c_str());
maxs.x = atof(strs[2].c_str());
maxs.y = atof(strs[3].c_str());
}
开发者ID:griver,项目名称:Shortest-paths-on-road-graphs,代码行数:15,代码来源:osm_loader.cpp
示例20: loadXML
void loadXML()
{
cout << "Parsing my beer journal..." << endl;
// Read the xml file into a vector
cout << "before loading a xml file" << endl;
ifstream theFile ("beerJournal.xml");
cout << "after loading a xml file" << endl;
vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
buffer.push_back('\0');
// Parse the buffer using the xml file parsing library into doc
doc.parse<0>(&buffer[0]);
// Find our root node
cout << "before parsing a root element" << endl;
root_node = doc.first_node("MyBeerJournal");
// Iterate over the brewerys
// elements = "sldfjlsdjfldsjfldsjflsdjflds";
elements=(char*) malloc(strlen(((((root_node)->first_node("Brewery"))->first_attribute("name"))->value()))+1);
strcpy ((char*)elements,(char*)(((root_node)->first_node("Brewery"))->first_attribute("name"))->value());
elements[strlen(((((root_node)->first_node("Brewery"))->first_attribute("name"))->value()))]='\0';
// elements = "char";
printf("here is element:%s\n",elements);
cout << "after parsing a root element" << endl;
if (root_node){
cout << "if there is a root element" << endl;
for (xml_node<> * brewery_node = root_node->first_node("Brewery"); brewery_node!=NULL; brewery_node = brewery_node->next_sibling())
{
cout << "here is in the for loop" << endl;
printf("I have visited %s in %s. ",
brewery_node->first_attribute("name")->value(),
brewery_node->first_attribute("location")->value());
// Interate over the beers
cout << "here is before the inner for loop" << endl;
for(xml_node<> * beer_node = brewery_node->first_node("Beer"); beer_node; beer_node = beer_node->next_sibling())
{
printf("On %s, I tried their %s which is a %s. ",
beer_node->first_attribute("dateSampled")->value(),
beer_node->first_attribute("name")->value(),
beer_node->first_attribute("description")->value());
printf("I gave it the following review: %s", beer_node->value());
}
cout << endl;
}
}
}
开发者ID:sunghee,项目名称:SRSdemo-dev,代码行数:48,代码来源:SRSdemo-dev.cpp
注:本文中的xml_document类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论