India Forums .Info

Discuss Cars, Bikes, Jobs, Romance, Marriage, Jobs, Real Estate, Programming and more..
It is currently Fri Nov 21, 2008 11:42 pm

All times are UTC + 5:30 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: XMLRead Function
PostPosted: Fri Feb 23, 2007 11:11 am 
Offline
Newbie

Joined: Tue Feb 06, 2007 4:50 pm
Posts: 37
XMLRead Function

The XMLRead function outputs an array of values returned by an XML expression. There are two required arguments: xmlfilepath and expression. Xmlfilepath is the absolute path to an XML file. expression is a valid node path or xml query in the specified XML file.


example usage:
Code:
<%
Dim i, a, strXMLPath, strXMLExpression

strXMLPath      = Server.MapPath("/aspemporium/examples/xmlcatalog/database.xml")
strXMLExpression    = "/CATALOG/MOVIE[RUNNINGTIME $gt$ 100]/RATING | " & _
             "/CATALOG/MOVIE[RUNNINGTIME $gt$ 100]/TITLE"
a           = XMLRead( strXMLPath, strXMLExpression )

For i = 0 To UBound(a) - 1
    Response.Write a(i) & "<BR>"
Next
%>
source code:
<%
Private Function XMLRead(ByVal xmlfilepath, ByVal expression)
    Dim temp, item, tmp, objXML, tmpArray
    On Error Resume Next
    Set objXML = Server.CreateObject("Microsoft.XMLDOM")
    objXML.Load( xmlfilepath )
    If Err Then
        On Error GoTo 0
        Err.Raise 5140, "XMLRead Function", _
                "Specified XML File Not Found."
        Err.Clear
        XMLRead = Null
        Set objXML = Nothing
        Exit Function
    End If
    Set temp = objXML.documentElement.selectnodes( expression )
    If Err Then
        On Error GoTo 0
        Err.Raise 5140, "XMLRead Function", _
                "Expression argument produced an error."
        Err.Clear
        XMLRead = Null
        Set objXML = Nothing
        Exit Function
    End If
    For Each item In temp
        tmp = tmp & item.text & vbCrLf & "/" & vbCrLf
    Next
    Set temp = Nothing
    Set objXML = Nothing
    tmpArray = Split( tmp, vbCrLf & "/" & vbCrLf )
    XMLRead = tmpArray
    On Error GoTo 0
End Function
%>


sourcecodesworld.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 5:30 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO