Overview
Features
Download
Documentation
Community
Add-Ons & Services

attributes.getLocalName(i) to std::string [solved!]

Please post support and help requests here.

attributes.getLocalName(i) to std::string [solved!]

Postby dagg » 15 Jun 2009, 06:09

I'm embarrassed to ask... :? I have a const Poco::XML::Attributes var which I want to extract the first attribute from it and convert it to string but no matter what I do, it fails compilation...
how can I extract it?
Last edited by dagg on 16 Jun 2009, 08:25, edited 1 time in total.
dagg
 
Posts: 18
Joined: 28 Mar 2008, 09:07

Re: attributes.getLocalName(i) to std::string

Postby alex » 15 Jun 2009, 19:36

Poco::XML::Attributes is abstract and can not be instantiated. Help us help you - post some code.
alex
 
Posts: 1130
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: attributes.getLocalName(i) to std::string

Postby dagg » 15 Jun 2009, 22:13

alex wrote:Poco::XML::Attributes is abstract and can not be instantiated. Help us help you - post some code.


I'm using a modified version of the SAXParser, using the same templete:
Code: Select all
void ConfigXmlHandler::startElement(const Poco::XML::XMLString& uri,const Poco::XML::XMLString& localname,const Poco::XML::XMLString& qname,const Poco::XML::Attributes& attributes) {
   mLevel++;
   switch(mLevel){
      case 1: levelOne(uri,localname,qname,attributes);
              break;
      case 2: levelTwo(uri,localname,qname,attributes);
              break;
      case 3: levelThree(uri,localname,qname,attributes);
              break;
      case 4: levelFour(uri,localname,qname,attributes);
              break;
   }
}
dagg
 
Posts: 18
Joined: 28 Mar 2008, 09:07

Re: attributes.getLocalName(i) to std::string

Postby alex » 15 Jun 2009, 22:35

dagg wrote:I'm using a modified version of the SAXParser, using the same templete:

I'm sorry, but I still do not understand what your problem is.

You said variable was const value. The code shows it to be const reference. What the compiler error is and which compiler you are using, we still do not know. If you are not willing to invest some time to provide a clear explanation of your problem, you shouldn't expect people to spend their time trying to figure it out.

Make a small example that someone can copy/paste and try to compile. Let us know what compiler you are using and what the error is.
alex
 
Posts: 1130
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: attributes.getLocalName(i) to std::string

Postby dagg » 16 Jun 2009, 07:23

like I've said, I'm using a modified version of your SAXParser without the locator.
on every time I enter a element, I increase the level counter.
when I'm geting into the fourth level I run this:
Code: Select all
180: void ConfigXmlHandler::levelThree(const Poco::XML::XMLString& uri, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname, const Poco::XML::Attributes& attributes) {
181:    std::string att=attributes.getLocalName(0);
182:    if ("name"==att) {
183:       mTag.append(":" + attributes.getValue(0));
184:    }
185: }

all function parameters are coming directly from the start element function, the output error is:
Code: Select all
181: error: invalid use of incomplete type `const Poco::XML::Attributes&`
ContentHandler.h:52: error: forward decleration of `const Poco::XML::Attributes&`
183: error: invalid use of incomplete type `const Poco::XML::Attributes&`
ContentHandler.h:52: error: forward decleration of `const Poco::XML::Attributes&`


I'm using poco 1.3.5 compiled from source and gcc 4.3.3
dagg
 
Posts: 18
Joined: 28 Mar 2008, 09:07

Re: attributes.getLocalName(i) to std::string

Postby guenter » 16 Jun 2009, 07:59

Have you #included'd "Poco/SAX/Attributes.h"?
guenter
 
Posts: 1129
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: attributes.getLocalName(i) to std::string

Postby dagg » 16 Jun 2009, 08:24

guenter wrote:Have you #included'd "Poco/SAX/Attributes.h"?


:o that is why I was embarrassed! thanks, I know something was missing!

damm! I need a vacation!

thanks alot!
dagg
 
Posts: 18
Joined: 28 Mar 2008, 09:07


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron