Attribute function getValue(...)

F

Fuy

Hi, i have a next problem:

In the method

startElement(const XMLCh* const uri,
const XMLCh *const localname,
const XMLCh *const qname,
const Attributes &attrs
){



string identifier = atts.getValue("id");


}
send next the error:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
error C2664: 'const XMLCh *xercesc_2_7::Attributes::getValue(const
unsigned int) const' : cannot convert parameter 1 from 'const char
[12]' to 'const unsigned int'
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

try this

startElement(const XMLCh* const uri,
const XMLCh *const localname,
const XMLCh *const qname,
const Attributes &attrs
){

for (int i = 0; i < atts.getLength(); i++) {
string value = atts.getValue(i);
}
}

and work,



In the first case why the error?, i see the code´s and no problems
using

string identifier = atts.getValue("id");

Any idea?

ok

ATTE
Fuy
 
J

Joe Kesselman

It might help to tell us what library you're working with. I presume
it's something in C++, judging from the syntax.

From what you've shown us, looks like the Attributes object is behaving
like an array and wants you to give the getValue operation an integer
offset into that array. There may be a completely different function for
retrieving attribute value by name. Read The Fine Manual?
 
F

Fuy

It true.

Use Xercesc, and lenguaje is C++.

The next link is the documentation the Attributes Class

http://xml.apache.org/xerces-c/apiDocs/classAttributes.html

and show howto get atributes

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

There are two ways for the SAX application to obtain information from
the Attributes. First, it can iterate through the entire list:

public void startElement (String uri, String localpart, String qName,
Attributes atts) {
for (int i = 0; i < atts.getLength(); i++) {
String Qname = atts.getQName(i);
String URI = atts.getURI(i)
String local = atts.GetLocalName(i)
String type = atts.getType(i);
String value = atts.getValue(i);
[...]
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
****2

As an alternative, the application can request the value or type of
specific attributes:

public void startElement (String uri, String localpart, String qName,
Attributes atts) {
String identifier = atts.getValue("id");
String label = atts.getValue("label");
[...]
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////

I use the ****2 but when compile the next


public void startElement (String uri, String localpart, String qName,
Attributes atts) {
String identifier = atts.getValue("id");
}

send this error:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
error C2664: 'const XMLCh *xercesc_2_7::Attributes::getValue(const
unsigned int) const' : cannot convert parameter 1 from 'const char
[12]' to 'const unsigned int'
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////


any of you have the error using Visual Studio 2005 C++ ??

ok

ATTE
Fuy

Joe Kesselman ha escrito:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,416
Messages
2,571,562
Members
48,797
Latest member
shadowoftheunknown

Latest Threads

Top