Master
'
s Thesis 2006 
FACHHOCHSCHULE
HOCHSCHULE F
U
R
LI Hui 
STUTTGART
TECHNIK
The implementation 
        STUTTGART UNIVERSITY OF APPLIED 
SCIENCES 
3.5  KXML XML Parser 
The  XML  parser  used  in  this  application  is  kXML  2.0.  In  order  to  make  kXML 
classes available to the application, kxml2 src.zip package from the kXML site need 
to  be  downloaded.  Then,  copy  the  contents of  the  package  to the 
src
  folder  in  the 
development system.   
As described before, the GetCapabilities XML document should be parsed. 
You can see one section of this XML document in Listing 19. 
<<
Service
>
<
Name
>
OGC:WMS
Name
>
   
<
Title
>
Open Source Map Server
Title
>
   
<
Abstract
>
Open source based WMS compliant Web Map Sever developed 
for educational purpose maintained by Filmon Mehari under supervision 
of Professor Dr. Ing. Franz Josef Behr .Contact: 
franz josef.behr@hft stuttgart.de or filmon44@yahoo.com.SVG data 
from all over the world. 
Abstract
>
   
<
KeywordList
>
<
Keyword
>
WMS 1.1.1
Keyword
>
   
   
.. 
Service
>
Listing 19:
 One section of the GetCapabilities XML document 
In  order to  capture  data  from  WMS,  the  application  should  open  a  URL  connection 
and  get  GetCapabilities  XML  data  on  an  InputStream.  The  InputStream  is  made 
available  to  the  XMLParser  through  an  InputStreamReader.  This  is  illustrated  in 
Listing 20. 
HttpConnection hc = (HttpConnection)Connector.open(url); 
InputStream is = hc.openInputStream(); 
Reader reader = new InputStreamReader(is); 
KXmlParser parser = new KXmlParser(); 
parser.setInput( reader); 
Listing 20:
 Get the GetCapabilities XML data from WMS 
When  the  XMLParser s 
read()
  method  encounters  an  item,  such  as  the  event  name 
(tag  name),  and  read  event  text  (that  is,  the  text enclosed  between  the  start  and  end 
tags, also called content). In Listing 21, the parser finds the tag name of title of WMS, 
then reads the content further and extractes the text for displaying purposes. 
46 




PHP MySql Web Hosting Design and Implement Client Applications PHP MySQL Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.