本文整理汇总了C++中XMLDocument类的典型用法代码示例。如果您正苦于以下问题:C++ XMLDocument类的具体用法?C++ XMLDocument怎么用?C++ XMLDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(XML_READER, getFirstChild)
{
XMLDocument * doc = XmlWrapper::loadDocument("UT/TestFiles/PDDB/test_pddb_1.xml");
XmlReader * reader = new XmlReader(doc);
XMLElement* doc_element;
std::string tag = "";
reader->goFirstChild();
reader->goFirstChild();
doc_element = doc->FirstChildElement();
doc_element = doc_element->FirstChildElement();
std::string a = XmlElementReader::getName(reader->getFirstChild(tag));
std::string b = XmlElementReader::getName(doc_element).c_str();
EXPECT_EQ(a, b);
delete reader;
delete doc;
}
开发者ID:fzmse,项目名称:fzmse,代码行数:18,代码来源:XmlReaderTest.cpp
示例2: parse
bool Triggers::parse() {
XMLDocument doc;
if (doc.LoadFile(mXmlFile.c_str())) {
doc.PrintError();
return false;
}
const XMLElement* root = doc.FirstChildElement("triggers");
if (! root)
return false;
const XMLElement* runs = root->FirstChildElement("runs");
for (; runs; runs = runs->NextSiblingElement("runs")) {
parseRunsElement(runs);
}
return true;
}
开发者ID:blinkseb,项目名称:GammaJetResiduals,代码行数:18,代码来源:triggers.cpp
示例3: write
void FileList::write() {
XMLDocument doc;
{
XMLElement* filelist = doc.NewElement("filelist");
filelist->SetAttribute("application", "video-organizer");
filelist->SetAttribute("version", "1.0");
for (unsigned i = 0; i < records.size(); i++) {
XMLElement* record = doc.NewElement("record");
record->SetAttribute("from", records[i].from.c_str());
record->SetAttribute("to", records[i].to.c_str());
record->SetAttribute("action", records[i].action);
filelist->InsertEndChild(record);
}
doc.InsertEndChild(filelist);
}
XMLError ret = doc.SaveFile((dir + "filelist").c_str());
if (ret) console.e("Error writing filelist: %s", ret);
}
开发者ID:JoelSjogren,项目名称:video-organizer,代码行数:18,代码来源:filelist.cpp
示例4: rss_feed_parse
void rss_feed_parse(const std::string &feed)
{
XMLDocument doc;
doc.Parse(feed.c_str());
XMLElement *rss = doc.FirstChildElement("rss");
if (rss) {
XMLElement *channel = rss->FirstChildElement("channel");
if (channel) {
for (XMLElement *article = channel->FirstChildElement("item"); article; article = article->NextSiblingElement("item")) {
XMLElement *title = article->FirstChildElement("title");
XMLElement *link = article->FirstChildElement("link");
std::cout << title->GetText() << std::endl;
std::cout << link->GetText() << std::endl;
std::cout << std::endl;
}
}
}
}
开发者ID:rohshall,项目名称:hnews,代码行数:18,代码来源:hnews.cpp
示例5: readSpecs
int SPECAPIENTRY readSpecs(const char* xmlData, unsigned int bytes,
Function** functions, unsigned int* functionCount,
Constant** constants, unsigned int* constantsCount)
{
XMLDocument document;
if (document.Parse(xmlData, bytes) == XMLError::XML_NO_ERROR)
{
XMLElement* registry = document.FirstChildElement("registry");
if (registry)
{
ObtainConstants(registry, constantsCount, constants);
ObtainCommands(registry, functionCount, functions);
ObtainFeatures(registry, functionCount, functions);
ObtainExtensions(registry, functionCount, functions);
}
}
return 0;
}
开发者ID:tak2004,项目名称:OpenGLVM,代码行数:18,代码来源:libSpec.cpp
示例6: addPluginByXML
void pluginManager::addPluginByXML(const char* name)
{
//fprintf(stderr,"[DEBUG] addPluginByXML(%s)\n",name);
XMLDocument doc;
doc.LoadFile(name);
// TODO add exception handle here
const char* libName = doc.FirstChildElement("libname")->GetText();
const char* funcName = doc.FirstChildElement("funcname")->GetText();
const char* freqs = doc.FirstChildElement("freq")->GetText();
int sleepInterval = atoi(freqs);
struct arguments A;
A.iv = sleepInterval;
addPlugin(libName ,funcName ,A);
}
开发者ID:xnum,项目名称:simpleDynamicLoading,代码行数:18,代码来源:pluginManager.cpp
示例7: apply_style
// Only public function of the module
void apply_style(XMLDocument const & xml, XMLDocument const & xsl,
std::ostream & out, std::ostream & err)
{
if (Validator(*xsl.root(), err)())
{
Document xsl_doc(xsl);
xsl_doc.apply_style_to(xml, out);
}
}
开发者ID:k-team,项目名称:xml-parser,代码行数:10,代码来源:style.cpp
示例8: xmlParse
void TR_svtImp::xmlParse(const string &set, vector< Ptr<Object> > &out)
{
XMLDocument doc;
doc.LoadFile(set.c_str());
XMLElement *root_ = doc.RootElement();
string rootElem(root_->Name());
if (rootElem == "tagset")
{
string strImage("image");
XMLElement *child = root_->FirstChildElement(strImage.c_str());
while (child)
{
string imageName = child->FirstChildElement("imageName")->GetText();
string lex = child->FirstChildElement("lex")->GetText();
Ptr<TR_svtObj> curr(new TR_svtObj);
curr->fileName = imageName;
split(lex, curr->lex, ',');
XMLElement *childTaggeds = child->FirstChildElement("taggedRectangles");
if (childTaggeds)
{
string strTagged("taggedRectangle");
XMLElement *childTagged = childTaggeds->FirstChildElement(strTagged.c_str());
while (childTagged)
{
tag t;
t.value = childTagged->FirstChildElement("tag")->GetText();
t.height = atoi(childTagged->Attribute("height"));
t.width = atoi(childTagged->Attribute("width"));
t.x = atoi(childTagged->Attribute("x"));
t.y = atoi(childTagged->Attribute("y"));
curr->tags.push_back(t);
childTagged = childTagged->NextSiblingElement(strTagged.c_str());
}
}
out.push_back(curr);
child = child->NextSiblingElement(strImage.c_str());
}
}
}
开发者ID:BKNio,项目名称:opencv_contrib,代码行数:44,代码来源:tr_svt.cpp
示例9: loadDatasetConfig
bool loadDatasetConfig(const string &filepath, ConfigXML &outConfigXML) {
cout << "Carregando ConfigXML... ";
// se houver problemas para abrir o arquivo, retorna false
XMLDocument doc;
XMLError error = doc.LoadFile(filepath.c_str());
if (error != XML_NO_ERROR) {
cout << "erro!" << endl;
return false;
}
// pega as configs do m�todo
XMLElement* configTag = doc.FirstChildElement("config");
outConfigXML.verbose = (strcmp(configTag->FirstChildElement("verbose")->GetText(), "true") == 0);
outConfigXML.display = (strcmp(configTag->FirstChildElement("display_images")->GetText(), "true") == 0);
outConfigXML.numParticles = configTag->FirstChildElement("particle_filter")->IntAttribute("num");
// pega as configs do dataset
XMLElement* dataset = doc.FirstChildElement()->FirstChildElement("dataset");
outConfigXML.dataset.id = dataset->Attribute("id");
outConfigXML.dataset.name = dataset->Attribute("name");
outConfigXML.dataset.path = dataset->Attribute("path");
outConfigXML.dataset.FrameSequence.start = dataset->FirstChildElement("frame_sequence")->IntAttribute("start");
outConfigXML.dataset.FrameSequence.end = dataset->FirstChildElement("frame_sequence")->IntAttribute("end");
outConfigXML.dataset.FrameSize.width = dataset->FirstChildElement("frame_size")->IntAttribute("width");
outConfigXML.dataset.FrameSize.height = dataset->FirstChildElement("frame_size")->IntAttribute("height");
outConfigXML.dataset._ROI.x = dataset->FirstChildElement("region_of_interest")->IntAttribute("x");
outConfigXML.dataset._ROI.y = dataset->FirstChildElement("region_of_interest")->IntAttribute("y");
outConfigXML.dataset._ROI.width = dataset->FirstChildElement("region_of_interest")->IntAttribute("width");
outConfigXML.dataset._ROI.height = dataset->FirstChildElement("region_of_interest")->IntAttribute("height");
outConfigXML.dataset._IPM.tr = dataset->FirstChildElement("ipm_points")->IntAttribute("top_right");
outConfigXML.dataset._IPM.tl = dataset->FirstChildElement("ipm_points")->IntAttribute("top_left");
outConfigXML.dataset._IPM.br = dataset->FirstChildElement("ipm_points")->IntAttribute("bottom_right");
outConfigXML.dataset._IPM.bl = dataset->FirstChildElement("ipm_points")->IntAttribute("bottom_left");
// Constr�i o ipm e a roi
setROI(outConfigXML);
setIPM(outConfigXML);
cout << "pronto!" << endl;
return true;
}
开发者ID:LCAD-UFES,项目名称:carmen_lcad,代码行数:44,代码来源:HelperXML.cpp
示例10: data
model::describe_volumes_response::describe_volumes_response(const string &xml_doc)
{
XMLDocument doc;
doc.Parse(xml_doc.c_str());
//Root
const XMLNode *RootNode = doc.FirstChild();
if (RootNode) {
set_string_value(RootNode, "requestId", request_id);
const XMLElement * Element = RootNode->FirstChildElement("volumeSet");
const XMLElement * ListElement = NULL;
if (Element)
ListElement = Element->FirstChildElement("item");
while(ListElement != NULL)
{
string status,volume_id, device, instance_id, snapshot_id,create_time;
bool encrypted = false;
string volume_type;
float size;
set_string_value(ListElement, "status", status);
set_string_value(ListElement, "volumeId", volume_id);
//Attachment set
const XMLElement* attachment = ListElement->FirstChildElement("attachmentSet");
if (attachment) {
const XMLElement* items = attachment->FirstChildElement("item");
if (items) {
set_string_value(items, "device", device);
set_string_value(items, "instanceId", instance_id);
}
}
set_string_value(ListElement, "snapshotId", snapshot_id);
set_string_value(ListElement, "createTime", create_time);
set_float_value(ListElement, "size", size);
set_bool_value(ListElement, "encrypted", encrypted);
model::volume data(status, volume_id, device, instance_id, snapshot_id, create_time, size, encrypted, volume_type);
volume_set.push_back(data);
ListElement=ListElement->NextSiblingElement();
}
}
}
开发者ID:JioCloudCompute,项目名称:jcs_cpp_sdk,代码行数:43,代码来源:describe_volumes_response.cpp
示例11: loadMap
bool TiledMap::loadMap(string source)
{
XMLDocument map;
map.LoadFile(source.data());
XMLElement* map_info = map.FirstChildElement("map");
this->version = map_info->Attribute("version");
this->orientation = map_info->Attribute("orientation");
this->width = this->stringToInt(map_info->Attribute("width"));
this->height = this->stringToInt(map_info->Attribute("height"));
this->tilewidth = this->stringToInt(map_info->Attribute("tilewidth"));
this->tileheight = this->stringToInt(map_info->Attribute("tileheight"));
this->loadTilesets(&map);
this->loadLayers(&map);
this->loadObjectGroups(&map);
}
开发者ID:corcrash,项目名称:Tiled-Map-Parser,代码行数:19,代码来源:tiledmap.cpp
示例12: data
model::describe_instance_types_response::describe_instance_types_response(const string &xml_doc)
{
XMLDocument doc;
doc.Parse(xml_doc.c_str());
//Root
XMLNode *RootNode = doc.FirstChild();
XMLElement *Element = RootNode->FirstChildElement("requestId");
if(Element!=NULL)
{
if(Element->GetText()!=NULL) request_id = Element->GetText();
Element=Element->NextSiblingElement();
}
else cout<<"Error Parsing request_id from XML describe_instance_types_response\n";
XMLElement *InstanceTypeElement,*ListElement = Element->FirstChildElement("item");
float vcpus,ram;
string id;
while(ListElement != NULL)
{
InstanceTypeElement = ListElement->FirstChildElement("vcpus");
if(InstanceTypeElement!=NULL)
{
InstanceTypeElement->QueryFloatText(&vcpus);
InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
}
else cout<<"Error Parsing VCPUS from XML describe_instance_types_response\n";
if(InstanceTypeElement!=NULL)
{
InstanceTypeElement->QueryFloatText(&ram);
InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
}
else cout<<"Error Parsing RAM data from XML describe_instance_types_response\n";
if(InstanceTypeElement!=NULL)
{if(InstanceTypeElement->GetText() != NULL)id = InstanceTypeElement->GetText();}
else cout<<"Error Parsing instance_id from XML describe_instance_types_response\n";
//Add to map
model::instance_type data(vcpus, ram, id);
instance_type_set.push_back(data);
ListElement=ListElement->NextSiblingElement();
}
}
开发者ID:devendermishrajio,项目名称:jcs_cpp_sdk,代码行数:43,代码来源:describe_instance_types_response.cpp
示例13: compareWithStorageFile
set<string> compareWithStorageFile(const string& path) {
map<string, time_t> storage;
XMLDocument doc;
if (doc.LoadFile(gStorage.c_str())!=XML_NO_ERROR) {
cerr << "Error reading XML!" << endl;
doc.PrintError();
}
auto root = doc.FirstChildElement();
auto file = root->FirstChildElement();
while (file) {
string name = file->FirstAttribute()->Value();
auto time = file->Attribute("last_modif");
storage[name] = stoll(time);
file = file->NextSiblingElement();
}
set<string> dst;
fs::path current(path);
fs::recursive_directory_iterator end;
cout << "Go to directory iterator: " << current.string() << " -> " << endl;
for (fs::recursive_directory_iterator item(current); item != end; ++item) {
if (!fs::is_directory(item->status())) {
fs::path filename = item->path();
time_t time = fs::last_write_time(filename);
auto sfile = filename.string().substr(current.string().size());
if (storage.count(sfile)>0) {
if (storage[sfile]!=time) {
dst.insert(sfile);
cout << "[mod] " << sfile << endl;
}
}
else {
dst.insert(sfile);
cout << "[new] " << sfile << endl;
}
}
}
return dst;
}
开发者ID:almikh,项目名称:patches-creator,代码行数:42,代码来源:patches-creator.cpp
示例14: vFile
bool CGBFile<GeomType, ValueType>::save(const std::string& directoryname, const std::string& fn, const Volume3d<GeomType, ValueType>& volume)
{
const std::string& filename = directoryname + "/" + fn;
XMLDocument xml;
XMLDeclaration* decl = xml.NewDeclaration();
xml.InsertEndChild(decl);
XMLNode* root = xml.NewElement("root");
xml.InsertEndChild(root);
{
XMLElement* res = xml.NewElement(resStr.c_str());
res->SetAttribute("x", volume.getResolutions()[0]);
res->SetAttribute("y", volume.getResolutions()[1]);
res->SetAttribute("z", volume.getResolutions()[2]);
root->InsertEndChild(res);
}
root->InsertEndChild( create(xml, originStr, volume.getStart()) );
root->InsertEndChild( create(xml, "length", volume.getSpace().getLengths()));
imageFileNames.clear();
{
XMLElement* e = xml.NewElement("volume");
e->SetAttribute("type", "unsigned char");
e->SetAttribute("format", "png");
VolumeFile vFile(directoryname);
for (size_t i = 0; i < volume.getResolutions()[2]; ++i) {
const auto iFile = vFile.toImageFile( "image", i, ImageFile::Type::PNG);
XMLElement* elem = xml.NewElement("image");
const auto& str = iFile.getFileNameIncludingPath();
elem->SetAttribute("path", str.c_str());
e->InsertEndChild(elem);
imageFileNames.push_back(str);
}
root->InsertEndChild(e);
}
//for (size_t i = 0; i < )
xml.SaveFile(filename.c_str());
return true;
}
开发者ID:SatoshiMabuchi,项目名称:CrystalGraphics,代码行数:47,代码来源:CGBFile.cpp
示例15: data
model::start_instances_response::start_instances_response(const string &xml_doc)
{
XMLDocument doc;
doc.Parse(xml_doc.c_str());
//Root
XMLNode *RootNode = doc.FirstChild();
XMLElement *Element = RootNode->FirstChildElement("requestId");
if(Element!= NULL)
{
if(Element->GetText() != NULL)request_id = Element->GetText();
Element = Element->NextSiblingElement();
}
XMLElement *ListElement = Element->FirstChildElement("item");
XMLElement *InstanceSetElement;
string instance_id, current_state, previous_state;
while(ListElement != NULL)
{
InstanceSetElement = ListElement->FirstChildElement("instanceId");
if(InstanceSetElement!=NULL)
{
if(InstanceSetElement->GetText()!=NULL)instance_id = InstanceSetElement->GetText();
InstanceSetElement=InstanceSetElement->NextSiblingElement();
}
else cout<<"Error Parsing instance_id from start_instances_response";
if(InstanceSetElement!=NULL)
{
current_state = InstanceSetElement->GetText();
InstanceSetElement=InstanceSetElement->NextSiblingElement();
}
else cout<<"Error Parsing current_state from XMl start_instances_response";
if(InstanceSetElement!=NULL)
{if(InstanceSetElement->GetText()!=NULL)previous_state = InstanceSetElement->GetText();}
else cout<<"Error Parsing previous_state from XML start_instances_response";
//Add to the map;
model::instance_set data(instance_id, current_state, previous_state);
instances.push_back(data);
ListElement=ListElement->NextSiblingElement();
}
}
开发者ID:sumanswaroop,项目名称:jcs_cpp_sdk,代码行数:42,代码来源:start_instances_response.cpp
示例16: xmlReadMeetingInfo
void XmlReader::xmlReadMeetingInfo(void)
{
XMLDocument doc;
doc.LoadFile(m_filename);
if (doc.ErrorID() != 0) {
printf("read xml error!\n");
return;
}
XMLElement *root = doc.FirstChildElement("root");
XMLElement *meetings = root->FirstChildElement("meetings");
for (XMLElement *meeting = meetings->FirstChildElement("meeting");
meeting;
meeting = meeting->NextSiblingElement("meeting")) {
XMLElement *meeting_id = meeting->FirstChildElement("meeting_id");
XMLElement *meeting_name = meeting->FirstChildElement("meeting_name");
XMLElement *start_time = meeting->FirstChildElement("start_time");
XMLElement *end_time = meeting->FirstChildElement("end_time");
XMLElement *meeting_conferrees = meeting->FirstChildElement("meeting_conferrees");
printf("meeting_id: %s\n", meeting_id->GetText());
printf("meeting_name: %s\n", meeting_name->GetText());
printf("start_time: %s\n", start_time->GetText());
printf("end_time: %s\n", end_time->GetText());
printf("conferreess:\n");
if (meeting_conferrees) {
for (XMLElement *meeting_conferree = meeting_conferrees->FirstChildElement("meeting_conferree");
meeting_conferree;
meeting_conferree = meeting_conferree->NextSiblingElement("meeting_conferree")) {
XMLElement *user2_id = meeting_conferree->FirstChildElement("user_id");
XMLElement *user2_account = meeting_conferree->FirstChildElement("user_acount");
XMLElement *user2_name = meeting_conferree->FirstChildElement("user_name");
printf("user_id: %s\n", user2_id->GetText());
printf("user_account: %s\n", user2_account->GetText());
printf("user_name: %s\n", user2_name->GetText());
}
}
printf("\n");
}
}
开发者ID:github188,项目名称:msm,代码行数:42,代码来源:xmlReader.cpp
示例17: XMLDocument
bool XMLOperation::fixAttribute1(const char *filePath, const char *elementId, const char *name, const char *value,const char* defId,bool fullPath)
{
std::string fullpath_str = filePath;
if (!fullPath)
{
fullpath_str.clear();
fullpath_str = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(filePath);
}
cout<<"修改文件读取的路径:"<<fullpath_str<<endl;
XMLDocument *pDoc = new XMLDocument();
pDoc->LoadFile(fullpath_str.c_str());
XMLElement *rootElement = pDoc->FirstChildElement();
XMLElement *xElement = rootElement->FirstChildElement();
bool isFixed = false;
while (xElement)//一条记录
{
if (strcmp(xElement->Attribute(defId),elementId) == 0)
{
xElement->SetAttribute(name, value);
// cout<<"属性id 值:"<<xElement->Attribute(defId)<<"比较id "<<elementId<<" name "<<name<<" value:"<<value<<endl;
if (pDoc->SaveFile(fullpath_str.c_str()) == XML_SUCCESS) {
isFixed = true;
}
break;
}
xElement = xElement->NextSiblingElement();
}
delete pDoc;
return isFixed;
}
开发者ID:GHunique,项目名称:CrazyGeography1,代码行数:42,代码来源:XMLOperation.cpp
示例18: XMLDocument
bool osmsMessageRegisterDigitalItemInstanceResponseError::decode(char* xmlText)
{
XMLDocument* pDoc = new XMLDocument();
if (pDoc == NULL)
return false;
if (!pDoc->decode(xmlText, getName()))
{
delete pDoc;
return false;
}
setMessageType(pDoc->getInteger("MessageType"));
setErrorCode(pDoc->getInteger("ErrorCode"));
setResponseString(pDoc->getString("ResponseString"));
delete pDoc;
return true;
}
开发者ID:gres147679,项目名称:openipmp,代码行数:20,代码来源:osmsMessageRegisterDigitalItemInstanceResponseError.cpp
示例19: loadGeometriesFromFile
// Static functions.
void loadGeometriesFromFile(std::vector<MeshGeometry> &geos, const char* filename) {
XMLDocument doc;
XMLConstHandle node(NULL);
doc.LoadFile(filename);
node = XMLConstHandle(&doc)
.FirstChildElement("COLLADA")
.FirstChildElement("library_geometries")
.FirstChildElement("geometry");
while (node.ToElement() != NULL && node.FirstChildElement("mesh").ToElement() != NULL) {
MeshGeometry mg = MeshGeometry();
mg.id = node.ToElement()->Attribute("id");
mg.name = node.ToElement()->Attribute("name");
loadMeshGeometry(mg, node.FirstChildElement("mesh"));
geos.push_back(mg);
node = node.NextSiblingElement("geometry");
}
}
开发者ID:ahwatts,项目名称:graphplay,代码行数:21,代码来源:Collada.cpp
示例20: main
int main (int argc, char const* argv[])
{
XMLDocument doc;
doc.LoadFile("resource/example4.xml");
XMLElement* element = doc.FirstChildElement("MyApp");
element = element->FirstChildElement("Messages")->FirstChildElement("value");
if(element){
float value;
element->QueryFloatText(&value);
cout<< value+2 << endl;
}else{
cout<<"not found"<<endl;
}
return 0;
}
开发者ID:jcarlosadm,项目名称:tutorials,代码行数:20,代码来源:test01.cpp
注:本文中的XMLDocument类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论