Example XMLIO operations
- Author
- MIP
#include <Base/Common/XMLIO.hh>
using namespace BIAS;
using namespace std;
int main (int , char** )
{
xmlNodePtr rootNode;
xmlNodePtr currentNode2;
xmlNodePtr currentNode3;
rootNode = myXML.
create(
"XMLTest");
myXML.
addAttribute(currentNode2,
"Attrib1", std::string(
"1234") );
myXML.
addAttribute(currentNode2,
"Attribute2", std::string(
"4321.1234") );
myXML.
addAttribute(currentNode2,
"NextAttribute", std::string(
"Content of attribute 3") );
std::string("The content of a node is written between the opening and closing tag.") );
currentNode3 = myXML.
addChildNode(currentNode2,
"ChildOfChild1");
myXML.
addAttribute(currentNode3,
"AttributeOfChildOfChild1", std::string(
"FULL") );
myXML.
addAttribute(currentNode3,
"AttributeWithUmlaute", std::string(
"özil") );
myXML.
addContent(currentNode3,
"myContent wtith umlaute. Schöner Mist");
myXML.
addAttribute(currentNode2,
"my Attribute", std::string(
"will produce an error") );
currentNode2 = myXML.
addChildNode(rootNode,
"ThisIsChild3");
myXML.
addAttribute(currentNode2,
"Roundness", std::string(
"Child 3 is very round") );
myXML.
addContent(currentNode2,
"Just some content");
if (myXML.
write(
"test.xml") <0) exit(1);
xmlAttrPtr currAttr;
rootNode = myXML.
read(
"test.xml");
if (rootNode == NULL) {
cout << "PARSING ERROR! Exiting XML-sample program...." << endl;
return 0;
}
while (currentNode2!=NULL) {
cout << endl << myXML.
getNodeName(currentNode2) << endl;
while (currAttr!=NULL) {
}
while (currentNode3!=NULL) {
cout << endl <<
" Child: " << myXML.
getNodeName(currentNode3) << endl;
cout << " Child Cont.: '" << content << endl;
while (currAttr!=NULL) {
}
}
}
cout << endl << endl << "Distinct Access:" << endl;
currentNode2 = myXML.
getChild(rootNode,
"ThisIsChild3");
if (currentNode2!=NULL) {
cout << "'Roundness' of 'ThisIsChild3': " <<
}
currentNode2 = myXML.
getChild(rootNode,
"Child1");
if (currentNode2!=NULL) {
cout << "'Attrib1' of 'Child1': " <<
cout << "'Attribute2' of 'Child1': " <<
}
return 0;
}