void test_iterator() { AFile_AString f("<inserted><var a=1 b=2 c=3/></inserted>"); AXmlElement element; element.fromAFile(f); std::cout << "element_name=" << element.getName() << std::endl; AXmlElement::NodeContainer::const_iterator cit = element.getContent().begin(); while (cit != element.getContent().end()) { AXmlElement *p = dynamic_cast<AXmlElement *>(*cit); if (p) { ARope rope; p->emitXml(rope); std::cout << " " << rope << std::endl; } ++cit; } }
int main(int argc, char* argv[]) { try { //a_XML dump AFile_AString stringfile("<root><c_0><gc_00/><gc_01>5</gc_01></c_0><c_1><gc_10/><gc_11/></c_1></root>"); AXmlElement element; element.fromAFile(stringfile); ARope rope; element.emitXml(rope, 0); // element.debugDump(); std::cout << rope.toString() << std::endl; } catch(AException& ex) { std::cerr << ex.what() << std::endl; } return 0; }
void __insert(AObjectContainer& ns) { AFile_AString f("<inserted><var a=1 b=2 c=3/><mixed>foo<bar/>baz</mixed></inserted>"); AXmlElement element; element.fromAFile(f); ARope rope; element.emitXml(rope); // element.debugDump(std::cout, 0); // std::cout << rope << std::endl; AObjectContainer nsNew; nsNew.fromElement(element); rope.clear(); element.clear(); nsNew.publish(element); // nsNew.debugDump(std::cout, 0); element.debugDump(std::cout, 0); element.emitXml(rope); // std::cout << rope << std::endl; ns.insert("/incoming/", nsNew.clone()); // ns.debugDump(std::cout, 0); }