我正在编写一个名为GetConfig.cpp
的xml解析器文件。
这是我的头文件'GetConfig.h`:
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMDocumentType.hpp>
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMNodeIterator.hpp>
#include <xercesc/dom/DOMText.hpp>
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
然而,当我尝试编译程序时,我得到:
/home/pribeiro/sandbox/GetConfig.cpp:372: error: 'class xercesc_2_2::DOMElement' has no member named 'getFirstElementChild'
/home/pribeiro/sandbox/GetConfig.cpp:381: error: 'class xercesc_2_2::DOMElement' has no member named 'getFirstElementChild'
/home/pribeiro/sandbox/GetConfig.cpp:392: error: 'class xercesc_2_2::DOMElement' has no member named 'getFirstElementChild'
/home/pribeiro/sandbox/GetConfig.cpp:396: error: 'class xercesc_2_2::DOMElement' has no member named 'getNextElementSibling'
我不知道为什么我会这样...... 在该声明中,我使用:
DOMElement *volume = dynamic_cast<xercesc::DOMElement*>
(volManager);
while(volume){
// to the parsing here
volume = volume->getNextElementSibling();
}
我不确定......也许与xercesc
版本相关的内容?当我为xercesc 3.1
编译时,它工作正常。
答案 0 :(得分:0)
这些功能是在Xerces 3中引入的
您可以在Xerces 3 API文档中看到它们:
http://xerces.apache.org/xerces-c/apiDocs-3/classDOMElement.html
但不在Xerces 2 API文档中:
http://xerces.apache.org/xerces-c/apiDocs-2/classDOMElement.html
字符串“getFirstElementChild”在Xerces 3.1.1源中出现31次,但在Xerces 2.8.0源中完全没有出现:
erik@ubuntu:/tmp$ file=http://archive.apache.org/dist/xerces/c/2/sources/xerces-c-src_2_8_0.tar.gz
erik@ubuntu:/tmp$ curl -s $file | tar xfz - -O | grep getFirstElementChild | wc -l
0
erik@ubuntu:/tmp$ file=http://archive.apache.org/dist/xerces/c/3/sources/xerces-c-3.1.1.tar.gz
erik@ubuntu:/tmp$ curl -s $file | tar xfz - -O | grep getFirstElementChild | wc -l
31
erik@ubuntu:/tmp$