C++ htmlcxx编译错误

C++ htmlcxx编译错误,c++,compiler-errors,C++,Compiler Errors,我尝试使用htmlcxx解析网页。 问题是,这个例子不是可编译的atm tree<HTML::Node>::iterator it = dom.begin(); tree<HTML::Node>::iterator end = dom.end(); for (; it != end; ++it) { if (it->tagName() == "A") { it->parseAttributes();

我尝试使用htmlcxx解析网页。 问题是,这个例子不是可编译的atm

tree<HTML::Node>::iterator it = dom.begin();
tree<HTML::Node>::iterator end = dom.end();
for (; it != end; ++it)
{
    if (it->tagName() == "A")
    {
        it->parseAttributes();
        std::cout << it->attributes("href");
        std::cout<< std::endl;
    }
}
tree::iterator it=dom.begin();
tree::iterator end=dom.end();
for(;it!=end;++it)
{
如果(它->标记名()=“A”)
{
它->解析属性();
std::cout属性(“href”);
std::CoutatAttributes(“href”);

其余的都很好,但有了这条线,我

错误:调用
'htmlcxx::HTML::Node::attributes(const char[5])时没有匹配的函数。

/usr/local/include/htmlcxx/html/Node.h:51:注意:候选项为:
const std::map&htmlcxx::html::Node::attributes()const


有人有想法吗?

看起来
attributes
函数没有将属性名称作为参数,而是返回映射中的所有属性。您应该阅读库文档以确认这一点。

我刚刚查看了源代码。您需要的函数是
attribute
,而不是
attributees

// attribute takes a string
std::pair<bool, std::string> attribute(const std::string &attr) const { ... }

// attributes takes nothing
const std::map<std::string, std::string>& attributes() const { return this->mAttributes; }
//属性接受一个字符串
std::pair属性(const std::string&attr)const{…}
//属性不需要任何东西
常量std::map&attributes()常量{返回此->mAttributes;}

我也遇到了同样的问题。有关使用htmlcxx的更多信息,我发现这些页面很有用(因为htmlcxx使用此树类):