FilePath XmlDomElement::getDocFilePath() const noexcept { XmlDomDocument* doc = getDocument(true); if (doc) return doc->getFilePath(); else return FilePath(); }
int main(int argc, char** argv) { string value; XmlDomDocument* doc = new XmlDomDocument("./bookstore.xml"); if (doc) { for (int i = 0; i < doc->getChildCount("bookstore", 0, "book"); i++) { printf("Book %d\n", i+1); value = doc->getChildAttribute("bookstore", 0, "book", i, "category"); printf("book category - %s\n", value.c_str()); value = doc->getChildValue("book", i, "title", 0); printf("book title - %s\n", value.c_str()); value = doc->getChildAttribute("book", i, "title", 0, "lang"); printf("book title lang - %s\n", value.c_str()); value = doc->getChildValue("book", i, "author", 0); printf("book author - %s\n", value.c_str()); value = doc->getChildValue("book", i, "year", 0); printf("book year - %s\n", value.c_str()); value = doc->getChildValue("book", i, "price", 0); printf("book price - %s\n", value.c_str()); } delete doc; } exit(0); }
int main(int argc, char** argv) { string value; //XmlDomDocument* doc = new XmlDomDocument("./bookstore.xml"); XmlDomDocument* doc = new XmlDomDocument(argv[1]); if (doc) { for (int i = 0; i < doc->getChildCount("setup", 0, "rpc"); i++) { std::cout<<"********************************************************" << std::endl; std::cout<<"Child No : " << (i+1) << std::endl; value = doc->getChildAttribute("setup", 0, "rpc", i, "id"); std::cout<<"Id : " << value << std::endl; value = doc->getChildValue("rpc",i,"gaps",0); std::cout<<"Number of Gaps : " << value << std::endl; value = doc->getChildValue("rpc",i,"roplanes",0); std::cout<<"Number of RO-Planes : " << value << std::endl; std::cout<<"RPC index : " << i << std::endl; for (int j = 0; j < doc->getChildCount("rpc", i, "plane"); j++) { value = doc->getChildAttribute("rpc", i, "plane", j, "id"); std::cout<<"------------------------------------------------------" << std::endl; std::cout<<"Plane ID : " << value << std::endl; //std::cout<<"TDC count in Plane : " << j <<" : " << doc->getChildCount("plane", j, "tdc") << std::endl; value = doc->getChildAttribute("rpc",i,"plane",j,"tdcid"); std::cout<<"TDC ID : " << value << std::endl; value = doc->getChildAttribute("rpc",i,"plane",j,"tdcchannelStart"); std::cout<<"Channel Start Index : " << value << std::endl; value = doc->getChildAttribute("rpc",i,"plane",j,"tdcchannelEnd"); std::cout<<"Channel End Index : " << value << std::endl; } } delete doc; } exit(0); }