Parsing XML from the Net Using the SAXParser
Parsing XML from the Net - Using the SAXParser
http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html
What you learn:
You will learn how to properly parse XML
(here: from the net
) using a SAXParser
.
What it will look like:
Description:
0.)
In this tutorial we are going to parse the following XML-File located at the following url: http://www.anddev.org/images/tut/basic/parsingxml/example.xml
:
XML:
<?xml
version
="1.0"
?>
<outertag>
<innertag
sampleattribute
="innertagAttribute"
>
<mytag>
anddev.org rulez =)
</mytag>
<tagwithnumber
thenumber
="1337"
/>
</innertag>
</outertag>
To accomplish the parsing, we are going to use a SAX-Parser
(Wiki-Info
). SAX
stands for "S
imple A
PI for X
ML
", so it is perfect for us
1.)
Lets take a look at the onCreate(...)
-method. It will open an URL
, create a SAXParser
, add a ContentHandler
to it, parse the URL
and display the Results
in a TextView
.
Java:
/** Called when the activity is first created. */
@Override
public
void
onCreate(
Bundle icicle)
{
super
.onCreate
(
icicle)
;
/* Create a new TextView to display the parsingresult later. */
TextView tv = new
TextView(
this
)
;
try
{
/* Create a URL we want to load some xml-data from. */
URL
url = new
URL
(
"http://www.
相关文档:
2009-12-19考了CET英语,心情很差,估计又不过的,哎!英文差!
于是看看书,看看自己感兴趣的书
今天下午,研究了整个下午的小难题,在8点40分终于搞定了!肚子饿,还没吃饭,还没洗澡,克服了一个不懂的小难题,心理有点体会,想在这里留点纪念,方便别人以后学习。于是乎,我写了:
(那些开训练器的相关介绍我就不再 ......
首先写一个html userxmljquery.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户校验ajax实例</title>
& ......
在上一篇文章中,我们讨论了如何通过javascript从一个远程XML文件中取得数据。在这篇文章中,我们将学会怎样对数据作更复杂的处理。作为一个示例,我们会准备一组XML数据,将数据分割成独立的片断并以不同的方式展示这些片断(取决于它们是如何被标识的)。
这篇文章是建立在上一篇文章中构造的示例代码的基础之上 ......
解决了,是1楼说的方法,不能写成
context.Response.ContentType = "xml";
必须要是
context.Response.ContentType = "text/xml";
就OK了~
实例:
Response.ContentType = "text/xml";
Page.Response.Write("<?xml version=\"1.0\" ......
这是关于Asp.Net/XML深入编程的技术书,作者精心设计了66个实例详细介绍了.Net Framework以及XML技术在.Net Framework的编程方法和技巧。全书由12章构成,内容包括.Net平台的建立、Asp.Net的Web Forms、控件、数据访问、Web Service、Asp.Net的设置和跟踪、Asp.Net的安全 ......