Content feed Comments Feed

The Official ASATO Site

Hi, welcome to my blog. ASP,asp.net,Health,Javascript,JQUERY

how to read XML file with asp?

Posted by admin On July - 1 - 2009

in this article,we will study how to reading xml file with asp.

first: what is xml file ?

XML is tag based just like HTML. there is a example:
<?xml version=”1.0″?>
<boot>
<name>Faisal Khan</name>
<name></name>
<name/>
<name language=”US-EN”>Faisal Khan</name>
</boot>

second: we save the xml file named “aspreadxml.xml”, and we will reading this xml with asp. we can get the xml document elements and attributes.
the code like this:

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0"?>
<%
dim xml,objNode,objAtr,nCntChd,nCntAtr
Set xml=Server.CreateObject("Microsoft.XMLDOM")
xml.Async=False
xml.Load(Server.MapPath("aspreadxml.xml"))
Set objNode=xml.documentElement
nCntChd=objNode.ChildNodes.length-1
for i=0 to nCntChd
set objAtr=objNode.ChildNodes.item(i)
nCntAtr=objAtr.Attributes.length-1
for j=0 to nCntAtr
response.write objAtr.Attributes.item(j).Text&"<br>"
next
response.write "<br>"
next
Set objAtr=Nothing
Set objNode=Nothing
Set xml=Nothing
%>

Comments are closed.