how can i get data from xml with syexpat
| Mon, 2007-04-09 07:17 | |
|
--------------------------------------------------------------------------------
i am newbie to syexpat,i download todd's software syexpat,i can run its example, in the Elements example, the emulator display the result ln: test and so on, for example <head> <test1>mydata1</test1> <test2>mydata2</test2> <test3>mydata3</test3> </head> how can i get mydata1? if i only want to get mydata2, what shuold i do, in the elements example the code(TSyExpatStatus status = reader->Parse(doc, ETrue); )doesnot display the content. i i can't grasp the functions of syexpat now. can someone give me some code or a example? |
|






Forum posts: 17
void StartElement(const TQualified& aName, const RArray<TAttribute>& attributes){
if(aName.iLocalName.Compare(_L("test1"))){
state = EStateT1;
}
}
In the CharacterData method extract the data
voidCharacterData(const TDesC& aData) {
if(state == EState1){
myvar1 = aData.AllocL(); //will be mydata1
}
}
Finally, reset the state in the EndElement method
void StartElement(const TQualified& aName){
if(aName.iLocalName.Compare(_L("test1"))){
state = EStateNone;
}
}
Forum posts: 26
i know the functions you said, but...
i dont know how to use the function, how to link the parameter of function to a tbuf, where is the data after running the function?
my example be store in a tbuf, how to get a tbuf that contains the data i want.
can you give me some codes?
Forum posts: 140
If you look in th examples folder, there is a project called elements, this has a simple example on how to parse xml content.
You can also look at my blog on Forum Nokia
http://blogs.forum.nokia.com/view_entry.html?id=475
which has some more details
Paul Todd
Forum posts: 17
class XmlParserMosaic : public MSyDocHandler, MSyDeclHandler {
public:
XmlParserMosaic();
~XmlParserMosaic();
CMosaicImageArray *Parse(const TDesC8 &xml);
TSyExpatStatus GetStatus() {return iStatus;}
TSyExpatError GetLastError() {return iError;}
// De MSyDocHandler
void StartElement(const TQualified& aName, const RArray<TMyAttribute>& attributes);
void EndElement(const TQualified& aName);
void CharacterData(const TDesC& aData);
void ProcessingInstruction(const TDesC& aTarget, const TDesC& aData);
void Comment(const TDesC& aData);
void StartCDataSection();
void EndCDataSection();
void Default(const TDesC& /*aData*/);
void SetParser(CExpatParserBase* aParser);
...
HBufC* GetMyvar();
private:
HBUfC* myvar1
}