Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : xml

Symbianѧϰ±Ê¼Ç(16) ½âÎöXMLÎļþ(ÏÂ)


×ÖºÅ:  С  ÖР ´ó  | ´òÓ¡ ·¢²¼: 2009-1-08 16:33    ×÷Õß: webmaster    À´Ô´: ±¾Õ¾Ô­´´    ²é¿´: 40´Î
Êé½ÓÉϻأ¬ÕâÆª½éÉÜÄǸöMContentHandlerµÄʵÏÖ£¬ÕâÊÇSAX½âÎö·½·¨µÄºËÐÄËùÔÚ¡£
ÏÈ¿´¿´ÎÒÒª½âÎöµÄXMLÎļþÈçÏÂËùʾ£¬ÆäʵºÜ¼òµ¥£¬ÒòΪËü³ýÁËElementºÍAttributeÒÔÍâûÓÐÆäËü¶«Î÷ÁË¡£
<?xml version="1.0" encoding="utf-8" ?>
<channels>
<channel id="10" title="ʱÕþ" >
<content id="1001" title="¹ã¶«Å£ÄÌÖж¾Ê¼þÎÛȾԴµ÷²é½á¹û1Öܺ󹫲¼"/>
<content id="1002" title="ºÓÄÏäÀ´¨¹«°²¾ÖÒò¶ùͯ±»¹Õ°¸Éè'¾Ö³ÜÈÕ'"/>
<content id="1003" title="ÉîÛÚ´óѧ135ÃûʦÉú¸ÐȾ²¡¶¾Òý·¢¸¹Ðº"/>
</channel>
<channel id="11" title="¹ú¼Ê">
<content id="1101" title="°ÍÒÔ½«ÓÚ4ÔÂ7ÈÕ»Ö¸´Áìµ¼È˼¶ºÍ̸"/>
<content id="1102" title="¹Å°Í½â³ý³¤ÆÚ½ûÁîÔÊÐí¹úÃñÈëסɿÍâ¾Æµê"/>
<content id="1103" title="ÁªºÏ¹ú¾ö¶¨¼ÌÐø¶Ô¸Õ¹û(½ð)ʵÐÐÎäÆ÷½ûÔË"/>
<content id="1104" title="¶í¾Ü¾ø½ÓÊÜÃÀ¹ú½ø¹¥ÐÔÕ½ÂÔÎäÆ÷ÎÊÌ⽨Òé"/> ......

How to parse XML file using CParser class


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() method). On each chunk, it passes the buffer to the XML parser. When the XML parser finds an element, it calls the respective callback functions, for example CXmlHandler::OnStartElementL() or CXmlHandler::OnEndElementL().
To use CParser class, the XmlFramework.lib has to be included in the .mmp file. For more information about CParser, please visit some links at the end of this page.
Contents
[hide]
 1 XmlHandler.h
 2 XmlHandler.cpp
 3 download example
 4 See Also
[edit] XmlHandler.h
#ifndef __XMLHANDLER_H__
#define __XMLHANDLER_H__
 
// INCLUDE FILES
#include <e32base.h>
#include <f32file.h>  // ......

Use the XML Parser in OS 9.x


Paul.Todd | 09 April, 2007 15:24
I have noticed a couple of people seem to be having problems with using the XML parser in Symbian and there are no examples outside of the devkit. The parser I will be talking about is the xml one, not the one SOAP engine as the SOAP one is Nokia specific.
The key to parsing XML is to understand how SAX based parsing works.
The key to using the Symbian XML API is to understand how SAX works and how its been implemented in Symbian.
SAX is at its core an event driven model that supports data being streamed, making it ideal for devices.
The foundation of the parser is the MContentHandler class which provides the callback interface you need to implement. In fact the first thing you need to do is to create a class deriving from MContentHandler that implements all of the pure virtual methods of MContentHandler
You can then create a CParser class and use your implementation of MContentHandler to provide the call backs required. You will normally only ......

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!
On ......

AndroidÅÄÕÕÉÏ´«³ÌÐòµÄxmlÅäÖÃÎļþ

1. login_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_logo"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/user_name"
/>
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:text="user"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
......

XMLѧϰ±Ê¼Ç£¨¶þ£©——XMLÔªËØÓëÊôÐÔ


XML ÔªËØ
ÔªËØÃüÃû
XMLÔªËØ±ØÐë×ñÊØÒÔϵÄÃüÃû¹æÔò£º
Ãû×ֿɰüº¬×Öĸ¡¢Êý×ÖÒÔ¼°ÆäËûµÄ×Ö·û
Ãû×Ö²»ÄÜÒÔÊý×Ö»òÕß±êµã·ûºÅ¿ªÊ¼
Ãû×Ö²»ÄÜÒÔ×Ö·û“xml”£¨»òÕßXML¡¢Xml£©¿ªÊ¼
Ãû×Ö²»Äܰüº¬¿Õ¸ñ
µ±Äú“·¢Ã÷´´Ôì”ÔªËØÃû³ÆÊ±£¬ÇëÁôÒâ²¢×ñÑ­ÏÂÃæµÄ¼òµ¥µÄ¹æÔò£º
Äú¿ÉÒÔʹÓóý±£Áô×ÖÍâµÄÈκÎÃû³Æ£¬µ«ÊÇÀíÏëµÄ×ö·¨ÊÇʹÃû³Æ¾ßÓÐÃèÊöÐÔ¡£Ê¹ÓÃÏ»®ÏßµÄÃû³ÆÒ²ÊDz»´íµÄ¡£
Àý×Ó: <first_name>£¬<last_name>
Ó¦¸ÃÔÚÃû³ÆÖбÜÃâ"-"ºÍ"."¡£±È·½Ëµ£¬Èç¹ûÄú½«Ä³¸öÔªËØÃüÃûΪ"first-name"£¬ÄÇôµ±ÄúµÄÈí¼þÊÔͼ´Ófirst¶ÎÀ´ÌáÈ¡Ãû³ÆÊ±¿ÉÄÜ»á³öÏÖ»ìÂҵľÖÃæ¡£»òÕßÈç¹ûÄú½«Ä³¸öÔªËØÃüÃûΪ"first.name"£¬ÄúµÄÈí¼þÒ²Ðí»áÈÏΪ"name"ÊÇ"first"¶ÔÏóµÄÒ»¸öÊôÐÔ¡£
ÔªËØÃû³Æ¿ÉÒÔÊÇÄãÏ£ÍûµÄÈκγ¤¶È£¬µ«ÊÇÒ²²»ÒªÌ«¿äÕÅ¡£Ãû³ÆÓ¦µ±±È½Ï¼ò¶Ì£¬±ÈÈ磺<book_title>£¬¶ø²»ÊÇ£º<the_title_of_the_book>¡£
XMLÎĵµ¾­³£ÓÐÒ»¸ö¶ÔÓ¦µÄÊý¾Ý¿â£¬ÆäÖеÄÓò»á¶ÔÓ¦XMLÎĵµÖеÄij¸öÔªËØ¡£ÓÐÒ»¸öʵÓõľ­Ñ飬¼´Ê¹ÓÃÊý¾Ý¿âµÄÃû³Æ¹æÔòÃüÃûXMLÎĵµÖеÄÔªËØ¡£
·ÇÓ¢ÓïµÄ×Öĸ±ÈÈçéòáÒ²ÊǺϷ¨µÄXMLÔªËØÃû£¬²»¹ýÐèҪעÒâµ±Èí¼þ¿ª·¢É̲»Ö§³Ö×Öĸʱ³öÏÖµ ......
×ܼǼÊý:815; ×ÜÒ³Êý:136; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [49] [50] [51] [52] 53 [54] [55] [56] [57] [58]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ