asp读取XML文件
<%
'
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET","http://127.0.0.1/1.xml",False
http.send
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
'xml.load (Server.MapPath("1.xml")) '如果不是远程文件直接这一步
xml.Load(http.ResponseXML)
Dim title, heading, paragraph, ii
title = xml.documentElement.childNodes(0).text
heading = xml.documentElement.childNodes(1).text
paragraph = xml.documentElement.childNodes(1).childNodes(1).childNodes(0).text
ii = xml.documentElement.childNodes(1).childNodes.length
dim i
for i=0 to ii-1
response.Write(i)
response.Write(xml.documentElement.childNodes(1).childNodes(i).childNodes(1).text)
response.Write("<br />")
next
Set xml = Nothing
%>
相关文档:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:XML id="xmlSource">
<node label="grandFather" state="unchecked">
<node label="Father" state="un ......
大量SmipleXML函数可用来加载和解析大量XML文档。
1.simpleXML_load_file()函数来加载指定的XML文件到对象。如果加载文件时遇到问题,则返回FLASE。例:
book.xml文件:
<?xml version="1.0" standalone="yes"?>
<library>
<book>
<title>Pride and Prejudice</title>
< ......
xml文件为:
<?xml version="1.0" encoding="UTF-8"?>
<mobile-list>
<mobile type="Nokia2652">
<wap2>false</wap2>
<width>115</width>
</mobile>
<mobile type="Nokia2650">
<wap2>false</wa ......
<!--#include file="inc/conn.asp" -->
<%
openconn()
sql="select * from tbnews"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
id=rs("id")
%>
<%
do while not rs.eof
%>
<%
Do_Url = "http://"
'Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME ......