本文整理汇总了C++中xml::Element::element_end方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::element_end方法的具体用法?C++ Element::element_end怎么用?C++ Element::element_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml::Element
的用法示例。
在下文中一共展示了Element::element_end方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testXmlFromString
void testXmlFromString() {
Xml::Document fromString;
fromString.readFromString(xmlJustAComment);
cout << "Just a comment: '" << fromString << "'\n";
fromString.readFromString(xmlPlainTextFile);
cout << "Plain text file: '" << fromString << "'\n";
// Note that the "condense white space" setting is global, not
// document-specific.
Xml::Document preserveWhite;
Xml::Document::setXmlCondenseWhiteSpace(false);
SimTK_TEST(!Xml::Document::isXmlWhiteSpaceCondensed());
preserveWhite.readFromString(xmlPlainTextFile);
cout << "Plain text file with white space preserved (raw): "
<< preserveWhite.getRootElement().getValue() << "\n";
cout << "... (formatted with condense=false): "
<< preserveWhite << "\n";
Xml::Document::setXmlCondenseWhiteSpace(true);
cout << "... (formatted with condense=true): "
<< preserveWhite << "\n";
SimTK_TEST_MUST_THROW(fromString.readFromString(xmlEmpty));
SimTK_TEST_MUST_THROW(fromString.readFromString(xmlUnclosedComment));
fromString.readFromString(String(xmlPainting));
cout << "Painting: '" << fromString << "'\n";
cout << "Doc type is: " << fromString.getRootTag() << endl;
cout << " version: " << fromString.getXmlVersion() << endl;
cout << " encoding: " << fromString.getXmlEncoding() << endl;
cout << " standalone: "
<< String(fromString.getXmlIsStandalone() ? "yes" : "no") << endl;
cout << "All nodes in doc:\n";
Xml::node_iterator np = fromString.node_begin();
for (; np != fromString.node_end(); ++np)
cout << " " << np->getNodeTypeAsString() << endl;
Xml::Element root = fromString.getRootElement();
cout << "hasNode()=" << root.hasNode() << endl;
cout << "hasNode(Comment)=" << root.hasNode(Xml::CommentNode) << endl;
cout << "hasNode(Unknown)=" << root.hasNode(Xml::UnknownNode) << endl;
showElement(root);
Xml::node_iterator p = root.node_begin(Xml::NoJunkNodes);
for (; p != root.node_end(); ++p)
cout << p->getNodeTypeAsString() << endl;
cout << "Caption elements:\n";
Xml::element_iterator ep(root.element_begin("caption"));
for (; ep != root.element_end(); ++ep)
cout << ep->getNodeTypeAsString() << ": <" << ep->getElementTag()
<< ">" << endl;
cout << "All elements:\n";
Array_<Xml::Element> all = root.getAllElements();
for (unsigned i=0; i < all.size(); ++i)
cout << "<" << all[i].getElementTag() << ">" << endl;
Array_<Xml::Node> allNodes(root.node_begin(Xml::NoJunkNodes),
root.node_end());
for (unsigned i=0; i < allNodes.size(); ++i)
cout << "Node " << allNodes[i].getNodeTypeAsString() << endl;
String prettyString, compactString;
fromString.writeToString(prettyString);
cout << "String pretty: " << prettyString.size()
<< "\n'" << prettyString << "'\n";
fromString.writeToString(compactString, true); // compact
cout << "String compact: " << compactString.size()
<< "\n'" << compactString << "'\n";
SimTK_TEST(compactString.size() < prettyString.size());
cout << "painting.allNode=" << root.getRequiredElement("painting")
.getAllNodes() << endl;
cout << "painting.img.allAttr=" <<
root.getRequiredElement("painting").getRequiredElement("img")
.getAllAttributes() << endl;
//fromString.writeToFile("TestXml.xml");
//Xml ex("TestXml.xml");
//cout << "Document tag: " << ex.getDocumentTag() << endl;
//for (Xml::nodu;e_iterator xp=ex.node_begin(); xp != ex.node_end(); ++xp)
// cout << "Node type: " << xp->getNodeTypeAsString() << endl;
//PolygonalMesh mesh;
//mesh.loadVtpFile("arm_r_humerus.vtp");
//cout << "num vertices=" << mesh.getNumVertices() << " faces="
// << mesh.getNumFaces() << endl;
}