Commit 2ae02c02 authored by Locatelli's avatar Locatelli

get file existing

parent f44b6052
......@@ -27,6 +27,7 @@
#include <xercesc/framework/LocalFileFormatTarget.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/validators/common/Grammar.hpp>
#include <boost/filesystem.hpp>
#include "NameServer.h"
#include "PersistenceServices/Configuration/XMLFileSetting.h"
......@@ -109,42 +110,44 @@ string XMLFileSetting::getIDs(const string& SettingFileName) {
filename.append(SettingFileName);
filename.append("Setting.xml");
// Parsing the DOM tree
try {
m_parser->parse(filename.c_str());
DOMDocument *document = m_parser->getDocument();
DOMNode* root = document->getDocumentElement();
DOMElement* element = 0;
if (root->getNodeType() == DOMNode::ELEMENT_NODE) {
element = (DOMElement *) root;
DOMNodeList* children = root->getChildNodes();
for (uint32 j = 0; j < children->getLength(); ++j) {
element = (DOMElement *) children->item(j);
if (ToChar(element->getTagName()).str() == SETTINGS_TAG) {
DOMNodeList* experimentChildNodes = element->getChildNodes();
for (uint32 k = 0; k < experimentChildNodes->getLength(); k++) {
DOMNode* childNode = experimentChildNodes->item(k);
if (childNode->getNodeType() == DOMNode::ELEMENT_NODE) {
if (ToChar(((DOMElement*) childNode)->getTagName()).str() == ID_TAG) {
id.append(ToChar(childNode->getFirstChild()->getNodeValue()).str());
id.append("|");
if (boost::filesystem::exists(boost::filesystem::path(filename))) {
// Parsing the DOM tree
try {
m_parser->parse(filename.c_str());
DOMDocument *document = m_parser->getDocument();
DOMNode* root = document->getDocumentElement();
DOMElement* element = 0;
if (root->getNodeType() == DOMNode::ELEMENT_NODE) {
element = (DOMElement *) root;
DOMNodeList* children = root->getChildNodes();
for (uint32 j = 0; j < children->getLength(); ++j) {
element = (DOMElement *) children->item(j);
if (ToChar(element->getTagName()).str() == SETTINGS_TAG) {
DOMNodeList* experimentChildNodes = element->getChildNodes();
for (uint32 k = 0; k < experimentChildNodes->getLength(); k++) {
DOMNode* childNode = experimentChildNodes->item(k);
if (childNode->getNodeType() == DOMNode::ELEMENT_NODE) {
if (ToChar(((DOMElement*) childNode)->getTagName()).str() == ID_TAG) {
id.append(ToChar(childNode->getFirstChild()->getNodeValue()).str());
id.append("|");
}
}
}
}
}
}
if (id.length() > 1)
id.erase(id.end() - 1);
if (id.length() > 1)
id.erase(id.end() - 1);
}
} catch (const XMLException& toCatch) {
cout << "Exception message is: \n" << ToChar(toCatch.getMessage()).str() << "\n";
} catch (const DOMException& toCatch) {
cout << "Exception message is: \n" << ToChar(toCatch.msg).str() << "\n";
} catch (const SAXException& toCatch) {
cout << "Exception message is: \n" << ToChar(toCatch.getMessage()).str() << "\n";
} catch (...) {
cout << "Unexpected Exception \n";
}
} catch (const XMLException& toCatch) {
cout << "Exception message is: \n" << ToChar(toCatch.getMessage()).str() << "\n";
} catch (const DOMException& toCatch) {
cout << "Exception message is: \n" << ToChar(toCatch.msg).str() << "\n";
} catch (const SAXException& toCatch) {
cout << "Exception message is: \n" << ToChar(toCatch.getMessage()).str() << "\n";
} catch (...) {
cout << "Unexpected Exception \n";
}
return id;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment