From Network Resources
Steps:
1 go to http://code.google.com/p/iksemel/download the latest iksemel1.4;
2. Add the header files under the include directory and Dom. C, IKS. C, ikstack. C, utility. C, and sax. C under the src directory to your project.
3. Remember to add the estlib. Lib library. Otherwise, the program will crash when using malloc.
4. The estlib. Lib file is in the libc directory. Therefore, add it to the MMP 5.
Code:
Parsexmll ()
{
_ Partition (kxmlfilename, "C: // food. xml ");
Rfile readfile;
Rfs fs;
FS. Connect ();
Tint err = readfile. Open (FS, kxmlfilename, efileread );
If (Err! = Kerrnone)
{
Readfile. Close ();
FS. Close ();
Return;
}
Tint filesize (0 );
Readfile. Size (filesize );
Hbufc8 * xmldata = hbufc8: newl (filesize );
Tptr8 ptr8 (xmldata-> des ());
Readfile. Read (ptr8 );
Ctextlistboxmodel * model = ilistbox-> model ();
Cdescarray * itemarray = static_cast <cdescarray *> (model-> itemtextarray ());
Tint OK;
IKS * root = iks_tree (char *) xmldata-> des (). PTR (), xmldata-> des (). Length (),
& OK );
If (OK = iks_ OK)
{
IKS * userslist = iks_find (root, "channel ");
IKS * userlist = iks_find (userslist, "item ");
While (userlist)
{
If (iks_type (userlist) = iks_tag)
{
// Name
Char * valuename = iks_find_cdata (userlist, "category ");
Tptrc8 ptrname (unsigned char *) valuename );
Hbufc * bufname = hbufc: newl (ptrname. Length ());
Tptr16 ptrname16 = bufname-> des ();
Cnvutfconverter: converttounicodefromutf8 (ptrname16, ptrname );
Ptrname16.trim ();
// Telephone number
Char * valuemobile = iks_find_cdata (userlist, "title ");
Tptrc8 ptrmobile (unsigned char *) valuemobile );
Hbufc * bufmobile = hbufc: newl (ptrmobile. Length ());
Tptr16 ptrmobile16 = bufmobile-> des ();
Cnvutfconverter: converttounicodefromutf8 (ptrmobile16,
Ptrmobile );
Ptrmobile16.trim ();
_ Substring (kstringheader2, "/T % S/T % s ");
Tbuf <50> buf2;
Buf2.format (kstringheader2 (), & ptrname16, & ptrmobile16 );
Itemarray-> appendl (buf2 );
Delete bufname;
}
Userlist = iks_next (userlist );
}
}
Iks_delete (Root );
Delete xmldata;
Readfile. Close ();
FS. Close ();
Ilistbox-> handleitemadditionl ();
}