本文整理汇总了C++中xml::Document::eraseTopLevelNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::eraseTopLevelNode方法的具体用法?C++ Document::eraseTopLevelNode怎么用?C++ Document::eraseTopLevelNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml::Document
的用法示例。
在下文中一共展示了Document::eraseTopLevelNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testXmlFromScratch
void testXmlFromScratch() {
Xml::Document scratch;
scratch.setRootTag("MyDoc");
cout << scratch;
Xml::Comment c("This is a comment.");
Xml::Unknown u("!GODONLY knows what this is!!");
Xml::Text t("This is some\ntext on two lines with trailing blanks ");
Xml::Element e("elementTag");
// We're never going to use this one so its heap space will
// leak if we don't explicitly call clearOrphan().
Xml::Element neverMind("neverMind");
cout << "initially e='" << e.getValue() << "'" << endl;
e.updValue() += "AVALUE:";
cout << "then e='" << e.getValue() << "'" << endl;
e.setAttributeValue("attr1", String(Vec2(9,-9)));
cout << "attr1 is " << e.getRequiredAttributeValueAs<Vec2>("attr1") << endl;
cout << "isOrphan? " << String(c.isOrphan()) << ":" << c;
cout << "isOrphan? " << String(u.isOrphan()) << ":" << u;
cout << "isOrphan? " << String(t.isOrphan()) << ":" << t;
cout << "isOrphan? " << String(e.isOrphan()) << ":" << e;
e.setValue("this is the only value");
e.updValue() += " (but then I added this)";
cout << "e value=" << e.getValue() << endl;
cout << "e = " << e << endl;
e.setValue("9 10 -3.2e-4");
cout << "e value=" << e.getValueAs< Array_<float> >() << endl;
cout << "e = " << e << endl;
scratch.insertTopLevelNodeAfter(scratch.node_begin(), c);
cout << "isOrphan? " << String(c.isOrphan()) << ":" << c;
cout << scratch;
scratch.insertTopLevelNodeBefore(scratch.node_begin(Xml::ElementNode), u);
cout << "isOrphan? " << String(u.isOrphan()) << ":" << u;
cout << scratch;
scratch.insertTopLevelNodeBefore(scratch.node_begin(),
Xml::Comment("This should be at the top of the file, except declaration."));
cout << scratch;
Xml::Document scratch2;
scratch2 = scratch; // deep copy
scratch.eraseTopLevelNode(scratch.node_begin());
cout << "First node gone (scratch)?\n" << scratch;
cout << "First node still there (scratch2)?\n" << scratch2;
Xml::Element e2("anotherElt", Vec3(.1,.2,.3));
cout << e2;
e.insertNodeAfter(e.element_end(), e2);
cout << "now owns anotherElt:\n" << e;
Xml::Element root = scratch.getRootElement();
root.insertNodeAfter(root.node_begin(), e);
cout << scratch;
scratch.setIndentString("..");
cout << scratch;
Xml::Element ecopy = e.clone();
ecopy.setElementTag("elementTagCopy");
cout << "COPY of e: " << ecopy;
//scratch.writeToFile("scratch.xml");
e.eraseNode(e.element_begin("anotherElt"));
cout << "in-place removal of anotherElt from e: " << scratch;
cout << "COPY of e: " << ecopy;
root.insertNodeAfter(root.element_begin("elementTag"), ecopy);
cout << "After copy insert, scratch=" << scratch;
Xml::Node extract = root.removeNode(root.element_begin("elementTagCopy"));
cout << "Extracted copy: " << extract << endl;
cout << "Now scratch=" << scratch << endl;
cout << "Duplicate scratch=" << Xml::Document(scratch) << endl;
neverMind.clearOrphan();
}