how can i get data from xml with syexpat
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,
i can't grasp the functions of syexpat now. can someone give me some code?
Re: how can i get data from xml with syexpat
Hi,
In your XMLHelper.cpp, you can find StartElement() and CharacterData() functions, In StartElement() function you can get the element name, and attributes and values and in CharacterData() you can get the element value.
regards,
eswar
Re: how can i get data from xml with syexpat
Hey...
I tried running GoogleIt and SyExpat on s60 3rd edition fp1 9.2v
but it does not compile.
Why? And how can I use XML parser for the version of sdk that I am using?
Re: how can i get data from xml with syexpat
Hey...
I just read that GoogleItFinal is meant for v2 and I need to update the package file to use it for other versions. I need it for the third version. How do I go about it?
Re: how can i get data from xml with syexpat
hi deepika_mangla,
i use the 2rd winscw, about 3rd, i can tell you nothing.sorry.
you can search "syexpat" in this forum,or in the newlc forum,you can find articles about how to install the program. one article tell me add two statement in .h file , sorry, i forget the file name.
Re: how can i get data from xml with syexpat
hi, eswar_illuri, thanx for your help.
but how to deal with the parameter of the StartElement function?
how to link the data with struct TQualified and RArray<TAttribute>?
could you give me a simple example?
thanx
Re: how can i get data from xml with syexpat
There are 3 Example included in Symbian/Exmaple folder in SyExpat. those may help you.
Re: how can i get data from xml with syexpat
[QUOTE=skumar_rao]There are 3 Example included in Symbian/Exmaple folder in SyExpat. those may help you.[/QUOTE]
elements example?
TSyExpatStatus status = reader->Parse(doc, ETrue);
it doesnot display the content.
can you give me a example?
Re: how can i get data from xml with syexpat
[QUOTE=zasdfaaa]elements example?
TSyExpatStatus status = reader->Parse(doc, ETrue);
it doesnot display the content.
can you give me a example?[/QUOTE]
Hi zasdfaaa,
if you are using the 3rd edition then parsing the xml file is very simple
you need to use three classes basically
CSenXmlReader* iReader;
CSenDomFragment* iDom;
CSenBaseElement* iRoot;
//make sure u include the library also
//You need to initialise the reader and dom class firstly
iReader = CSenXmlReader::NewL( EConvertTagsToLowerCase | ELastFeature );
iDom = CSenDomFragment::NewL();
//need to paas the handles of reader and dom to each other
iDom->SetReader(*iReader);
iReader->SetContentHandler(*iDom);
//this is the last one which does all the parsing thru the file
iReader->ParseL(iSession,aFileName);
// get root of tree
iRoot = (CSenBaseElement*)iDom->ExtractElement();
once u get the root of the tree its the simple parsing of the tree that is required
hope this helps
Re: how can i get data from xml with syexpat
Sohil, thank you very much!
when i use the 3rd platform, i will deal xml follow your code.
but ......
i must do it in the 2rd platform............... :(
thank again!
Re: how can i get data from xml with syexpat
can anyone help me?please.
Re: how can i get data from xml with syexpat
What is the Problem with 2nd Edition. it must be straight forward there.
Re: how can i get data from xml with syexpat
hi, Sohil
i do follow your step, but,
iRoot = (CSenBaseElement*)iDom->ExtractElement();
the iRoot can get nothing! why?
plz help me.
my code:
_LIT8(xmlcontent, " <?xml version = \"1.0\"> "
" <testhead>1111111 "
" <test1>22222</test1> "
" <test2>333333</test2> "
" <test3>444444</test3> "
" </testhead> " );
//TBuf8<256>xmlbuf(xmlcontent);
//TPtrC8 xmlptrc(xmlcontent);
//xml process
CSenXmlReader* iReader;
CSenDomFragment* iDom;
CSenBaseElement* iRoot;
iReader = CSenXmlReader::NewL( EConvertTagsToLowerCase | ELastFeature );
iDom = CSenDomFragment::NewL();
////////////////////////get each other/////////////////////////////
iDom->SetReader(*iReader);
iReader->SetContentHandler(*iDom);
////////////////////////parse/////////////////////////////////
iReader->ParseL(xmlptrc);
////////////////////get element////////////////////////////////
iRoot = (CSenBaseElement*)iDom->ExtractElement(); iRoot->Child(2);// i want to read text of test1
TPtrC8 texttptrc = iRoot->Content();//i want to write text to tprc
can these codes get text(22222) that i want?