I'm new to mosync and app development. I would like to use the xml parser to extract some information (a list of users) from a web page that I download using a http connection. When I try to parse the data the app crashes (in an android 2.0 emulator) with panic code 40035.
Here is my parser:
class UserListParser :
private Mtx::XmlListener,
private Mtx::MtxListener
{
public:
void parse(MAUtil::String& tagdata);
private:
// for test purposes (I derive a screen from UserListParser that implements
// someEvent() and have it display a debug message)
virtual void someEvent(MAUtil::String stuff) = 0;
// from XmlListener
void mtxEncoding(const char* value);
void mtxTagStart(const char* name, int len);
void mtxTagAttr(const char* attrName, const char* attrValue);
void mtxTagStartEnd();
void mtxTagData(const char* data, int len);
void mtxTagEnd(const char* name, int len);
void mtxParseError(int offset);
void mtxEmptyTagEnd();
unsigned char mtxUnicodeCharacter(int unicode);
// from MtxListener
void mtxDataRemains(const char* data, int len);
// private members
MAUtil::String tagdata;
Mtx::Context parser;
};here is the implementation of the only public method:
void UserListParser::parse(MAUtil::String& tagdata)
{
// copy the data
UserListParser::tagdata = tagdata;
// start parsing, here is where it crashes
parser.feed(tagdata.pointer());
// the following line is not executed
someEvent("not crashed... yet");
}
here is what happens in the screen (which is derived from UserListParser):
void TextScreen::someEvent(MAUtil::String stuff)
{
addText(stuff);
}
void TextScreen::addText(const MAUtil::String& str)
{
MAUtil::String text = mainLabel->getText();
text.append("\n", 1);
text.append(str.c_str(), str.length());
mainLabel->setText(text);
}I imagine it is maybe a problem with the string handling.
Is the char* data returned by String::pointer() zero-terminated? What is the difference between pointer() and c_str()?
What could I possibly be doing wrong? Thanks for any help with this.
I hope I'm in the right section of the forum with this question.