Hi,
I'm new in C++ programming and I'm trying to create a
little program the parse some xml inside a zip file. For the
zip part I used the library
https://bitbucket.org/wbenny/ziplib
and for parsing the xml I want to use libxml++.
The problem is that I get this error with g++ that I realy
don't understand:
src/zip/UnzipFile.cc: In member function ‘void
Dopc::UnzipFile::open(const string&)’:
src/zip/UnzipFile.cc:50:54: error: no matching function for
call to
‘xmlpp::DomParser::parse_stream(std::basic_istream<char>**)’
parser.parse_stream(&decompressStream);
^
In file included from
/usr/local/include/libxml++-3.0/libxml++/libxml++.h:54:0,
from src/zip/UnzipFile.cc:6:
/usr/local/include/libxml++-3.0/libxml++/parsers/domparser.h:75:8: note:
candidate: virtual void
xmlpp::DomParser::parse_stream(std::istream&)
void parse_stream(std::istream& in) override;
^~~~~~~~~~~~
/usr/local/include/libxml++-3.0/libxml++/parsers/domparser.h:75:8:
note: no known conversion for argument 1 from
‘std::basic_istream<char>**’ to ‘std::istream&
{aka std::basic_istream<char>&}’
This is the code of my program:
void UnzipFile::open(const string& p_fileName)
{
ZipArchive::Ptr archive = ZipFile::Open(p_fileName);
size_t entries = archive->GetEntriesCount();
printf("[o] Listing archive (comment: '%s'):\n",
archive->GetComment().c_str());
printf("[o] Entries count: %lu\n", entries);
for (size_t i = 0; i < entries; ++i)
{
auto entry = archive->GetEntry(int(i));
if (entry->GetFullName() ==
"[Content_Types].xml")
{
auto decompressStream =
entry->GetDecompressionStream();
printf("[o] -- %s\n", "File XML
decompress");
try{
xmlpp::DomParser parser;
parser.set_validate();
parser.parse_stream(&decompressStream);
if (parser)
{
const auto pNode =
parser.get_document()->get_root_node();
cout << "XML READ SUCCESS"
<< endl;
}
} catch (const std::exception& ex){
cerr << "Exception caught: " <<
ex.what() << endl;
}
} else {
printf("[o] -- %s\n",
entry->GetFullName().c_str());
}
}
printf("\n");
}
The strange is that "decompressStream" is a std::istream
like the one that parse_stream want. But g++ say the is a no
known conversion.
Thanks in advance for your help.
Regards
Marco