Advertise Here
XML Files - Extensible Markup Language Tutorials for Developers - ?
Extensible Markup Language

Search XML Files

XML Files RSS Feed XML Files Updates

 


A Couple of ASP Functions for XML Data Transfer

By
sjuarez1979@hotmail.com

Introduction

One of our visitors decided they would give something back. It's not much, but here are a couple of ASP functions for XML Data transfer that they found to be very useful.

Two functions that allow for XML Data transfer

getXMLField


Function getXMLField(strFieldName)

    Dim objDom
    Dim objRoot
    Dim objField
    Dim strFile
    Dim PageNo

    PageNo = Request.QueryString("page")
    If PageNo = "" Then
        PageNo = "1"
    End If

    'Page Number
    strFile = "Page" & PageNo & ".xml"

    'XML file object
    Set objDom = Server.CreateObject("Microsoft.XMLDOM")
    objDom.async = False
    strXMLFile = Server.MapPath(strFile)
    objDom.Load (strXMLFile)

    'Root XML Field
    Set objRoot = objDom.documentElement

    'collect information from nodes
    Set objField = objRoot.selectSingleNode(strFieldName)

    getXMLField = objField.Text

    'Release variables
    Set objDom = Nothing
    Set objRoot = Nothing
    Set objField = Nothing

End Function

updateXMLField


Function updateXMLField(strFieldName, strData2BInserted, strXMLFile)

    Dim objDom
    Dim objRoot
    Dim objField

    'XML file object
    Set objDom = Server.CreateObject("Microsoft.XMLDOM")
    objDom.async = False
    objDom.Load strXMLFile

    'Root XML Field
    Set objRoot = objDom.documentElement

    'Select single XML node given the node name
    Set objField = objRoot.selectSingleNode(strFieldName)

    'update field
    objField.Text = strData2BInserted

    objDom.save strXMLFile
    updateXMLField = True

    'Release all objects
    Set objDom = Nothing
    Set objRoot = Nothing
    Set objField = Nothing

End Function

Thanks to sjuarez1979@hotmail.com for the above code!

If you've got an article or a code snippet that you'd to share, drop us an email.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 DevX XML Content 
- Easily Create Responsive Websites Using Bootstrap

Jump to : Top Of Page or HOME