Overview
Features
Download
Documentation
Community
Add-Ons & Services

[XML] Error using parse(InputSource* pInputSource)

Please post support and help requests here.

[XML] Error using parse(InputSource* pInputSource)

Postby dbarzo » 14 Jan 2013, 17:31

Hi,

I'm trying to use the XML namespace and the following code to load a document:

Code: Select all
AutoPtr<XML::Document> m_xmlConfig;

XML::InputSource src(std::ifstream(schemaFile));
m_xmlSchema.assign(parser.parse(&src));


but I get the following compiler error:

error C2664: 'Poco::XML::Document *Poco::XML::DOMParser::parse(const Poco::XML::XMLString &)': cannot convert parameter 1 from 'Poco::XML::InputSource (__cdecl *)(std::ifstream)' to 'const Poco::XML::XMLString &'

It seems to not "view" the method
Document* parse(InputSource* pInputSource);

I'm using VS2010. Any suggestions?

Regards,
Daniele.
dbarzo
 
Posts: 39
Joined: 14 Jan 2013, 17:15
Location: Italy

Re: [XML] Error using parse(InputSource* pInputSource)

Postby alex » 14 Jan 2013, 17:59

dbarzo wrote:Any suggestions?

Try:

Code: Select all
std::ifstream ifs(schemaFile)
XML::InputSource src(ifs);
m_xmlSchema.assign(parser.parse(&src));

For explanation, see most vexing parse, for long-term solution C++11 uniform initialization.
alex
 
Posts: 1145
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: [XML] Error using parse(InputSource* pInputSource)

Postby dbarzo » 15 Jan 2013, 11:28

Thanks a lot alex!!!
I didn't know about the most vexing parse! :-)

Regards,
Daniele.
dbarzo
 
Posts: 39
Joined: 14 Jan 2013, 17:15
Location: Italy


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron