Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7518861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:48:38+00:00 2026-05-30T01:48:38+00:00

This site was working properly before I started encountering an error after entering some

  • 0

This site was working properly before I started encountering an error after entering some code. The code was not on the home page but none of the site pages will load now. I restarted the site in IIS and that did not help.

Here is the code that I entered:

'Prepare to parse XML
Set objXML = Server.CreateObject(Microsoft.XMLDOM)

'Set Asynchoronous = false
objXML.async = False

'Load the XML file.
'User Server.MapPath method is the XML is located in your site.
'Else you can use the absolute path.
objXML.Load (Server.MapPath(Products.xml))

'If there is any errors pasring the file the notify
If objXML.parseError.errorCode = 0 Then        
    'Response.Write(objXML.parseError.reason)
Else objXML.parseError.errorCode <> 0 Then
    'Get ALL the Elements by the tag name product
    Set products = objXML.getElementsByTagName(product)

    Select Case iItemID
        Case 1
            aParameters = Array(products.item(0).childNodes(0).text, products.item(i).childNodes(2).text, products.item(i).childNodes(2).text)
        Case 2
            aParameters = Array(products.item(1).childNodes(0).text, products.item(i).childNodes(2).text, products.item(i).childNodes(2).text)        
    End Select

    ' Return array containing product info.
    GetItemParameters = aParameters
End If

Running IIS in Windows 7 using classic ASP. Editing with Notepad++.

Here is the XML file:

<configuration>
<products>
    <product>   
        <image>
            <![CDATA[ /Images/Atlas Gloves.jpg ]]>
        </image>    
        <name>
            <![CDATA[ Atlas Nitrile Touch Gloves ]]>
        </name>
        <description>
            <![CDATA[ Atlas Nitrile Touch is available in 6 vibrant colors, and is America’s #1 glove for the Lawn and Garden market. Atlas gloves have a breathable nylon back and are machine washable. Like a “second skin,” these gloves are the most comfortable! Atlas Nitrile gloves are the #1 gardening gloves. Atlas Nitrile gloves act like a "second skin" between the user and their work, offering full dexterity and grip. Atlas Nitrile Gloves are perfect for gardening, but their uses expand to so many places – the woodshop, the workshop, the workplace. ]]>
        </description>
        <size>
            <![CDATA[ Small, Medium ]]>
        </size>
        <color>
            <![CDATA[ Purple, Pink, Green, Orange ]]>
        </color>
    </product>
</products>
</configuration>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:48:39+00:00Added an answer on May 30, 2026 at 1:48 am

    Lets start by getting the code in order:

    First we’ll create a little helper function which given a parent XML element and an XPath (can be simply a tagName of a child element) will return the text value of an element. In this case I have deliberately choosen to return null if the element isn’t found but you could leave the return value empty if you prefer:

    Function GetElemText(parentElem, path)
         Dim elem: Set elem = parentElem.selectSingleNode(path)
         If Not elem Is Nothing Then
             GetElemText = elem.text
         Else
             GetElemText = null
         End If
    End Function
    

    Now we’ll create a little VBScript class which has a field for each of the product elements. This class has a LoadFromXml method which given an product xml element will extract the field values.

    Class Product
    
        Public Image
        Public Name
        Public Description
        Public Size
        Public Color
    
        Public Sub LoadFromXml(prodElem)
             Image = GetElemText(prodElem, "image")
             Name = GetElemText(prodElem, "name")
             Description = GetElemText(prodElem, "description")
             Size = GetElemText(prodElem, "size")
             Color = GetElemText(prodElem, "color")
        End Sub
    
    End Class
    

    Finally we create a GetProduct function that given the index of a product will load return a Product class instance loaded with the appropriate product details.

    Function GetProduct(productIndex)
    
        Dim objXML: Set objXML = Server.CreateObject("MSXML2.DOMDocument.3.0") 
    
        objXML.async = False 
        objXML.setProperty "SelectionLanguage", "XPath"
        objXML.Load Server.MapPath("Products.xml") ''# Assumes Products xml in same folder as this script 
    
        Dim elem: Set elem = objXML.documentElement.selectSingleNode("products/product[" & productIndex & "]") 
        If Not elem Is Nothing Then
            Set GetProduct = new Product
            GetProduct.LoadFromXml elem
        Else
            Set GetProduct = Nothing
        End If
    
    End Function
    

    Note the use named elements eliminates the need for “magic numbers” the values of which you would either have to remember or place in constants and are very fragile. Also the use of XPath as the selection language and a more specific ProgID. All in all much more robust and in this case also working.

    If your products xml remains fairly static over the life time of the application consider this variation of:

    Function GetProduct(productIndex)
    
        Dim objXML
        If IsEmpty(Application.Contents("Products")) Then
            Set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0") 
            objXML.async = False 
            objXML.setProperty "SelectionLanguage", "XPath"
            Set Application.Contents("Products") = objXML
        Else
            Set objXML = Application.Contents("Products")
        End If
    
        objXML.Load Server.MapPath("Products.xml") ''# Assumes Products xml in same folder as this script 
    
        Dim elem: Set elem = objXML.documentElement.selectSingleNode("products/product[" & productIndex & "]") 
        If Not elem Is Nothing Then
            Set GetProduct = new Product
            GetProduct.LoadFromXml elem
        Else
            Set GetProduct = Nothing
        End If
    
    End Function
    

    This loads the XML DOM into the application store saving the cost of reloading every time a product is needed.

    One other change I would recommend, the reliance of know the ordinal position of a product element in order to retrieve it is quite fragile. Consider adding an id="1" attribute to the product element. It can then be retrieved with:

        Dim elem: Set elem = objXML.documentElement.selectSingleNode("products/product[@id=""" & productIndex & """]")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on this site: http://gitastudents.com/~clarkb/group1/Students.html For some reason it does not display
Im using this jquery code to switch page content on my site. It switches
for some reason my server that uses socket.io is not working properly. The program
So I'm working on this site web app that should let users easily chat
I'm working on a sample i found on this site: http://kevinmusselman.com/blog/2009/02/access-webcam-with-flash/ it captures the
I have this classic ASP site which has been working fine until we updated
Very odd problem as this is working perfectly on our old Classic ASP site.
From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by
for this site: http://yoursdproperty.com/ do you see how there some extra white space all
I'm currently working on a TimerJob which does some site collections management. When the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.