Example Code of Using XML Parser in Symbian OS
antonypr | 14 April, 2007 00:05
A couple of weeks ago, I had a plan to write an article and example code of using XML parser in Symbian OS. It seems that another Forum Nokia Champion, Paul Todd had the same idea. He posted a nice article about XML parser in Symbian OS 9.x to Forum Nokia Blogs. It's good that I don't need to write the same article. :)
What I would like to share here is a complete example code of XML Parser in Symbian OS. The example code can be run on Symbian OS 8 and 9 phones, which means it can be compiled under S60 2nd Edition FP2/FP3 SDK or S60 3rd Edition SDK. I am planning to release the same example code for UIQ3 soon.
Click here to download my example code of XML parser
The example basically parses an XML file, dataexample.xml, to the main window. The content will be displayed on CEikEdwin control (see picture below).
Note that the code is written as an example; thus it is designed to be as simple as possible. Do not use it in the production code!
One more thing, this is not the official example code from Forum Nokia. It is just my personal example code.
S60, Symbian C++ | Next | Previous | Comments (11) | Trackbacks (0)
Comments
Re: Example Code of Using XML Parser in Symbian OS
sandordornbush | 17/05/2007, 20:52
This is great starting point. However I need to parse a fairly large file (~8kB). Can you give any advice how to adapt this code to one where the whole file does not need to be loaded in one shot? I also posted this on the forums at:
http://discussion.forum.nokia.com/forum/showthread.php?t=108183
Re: Example Code of Using XML Parser in Symbian OS
jp4symbian | 13/06/2007, 15:26
This is an extremely useful example for parsing Xml specially since there is no such example on Forum.Nokia.
I have studied your example and have been able to successfully parse my Xml. But I also need to parse the tag attributes which is not implemented in your example.
I assume that attributes o
相关文档:
首先将dom4j-1.6.1.jar,jaxen-1.1.1.jar两个jar包导入到项目中
reader_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<db-info>
<driver-name>oracle.jdbc.driver.OracleDriver</driver-name>
<url>jdbc:oracle:thin:@192.168.1.100:1521:orcl</url>
......
private void WriteXML()
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?> ");
sb.Append(" <!-- ");
sb.Append("<content>");
sb.Append(& ......
(第1章)
(P1~3)1.用自己的语言对SGML、HTML和XML作简单介绍和对比。
SGML 是一种采用标记来描述文档数据的通用语言,SGML定义了基本的语法好,同时也允许用户建立自己的元素标记。
HTML 采用了很小一部分SGML的标记,同时HTML采用的是固定标记也不需要包含DTD。
XML 同HTML一样,都是出自于SGML标准通用标记语 ......
解析:
CMarkup xml;
CString strChanText, strChanType;
xml.Load("MyXml.xml");
xml.ResetMainPos();
if (!Chan.FindElem("TreeOrg"))
{
return;
}
if (xml.IntoElem())
{
xml.FindEle ......
Reviewer Approved
The following example shows how to parse XML file using Symbian OS C++ class, CParser. CParser is basically a SAX (Simple API for XML)-based XML parser.
It uses an active object to read the XML file chunk by chunk (see CXmlHandler::StartParsingWithAoL( ......