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 7864585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:49:47+00:00 2026-06-02T23:49:47+00:00

I have been all over the web looking for a clean way to change

  • 0

I have been all over the web looking for a clean way to change 2 attributes in an XML node using VBS (unfortunately my only choice for this with this client). The XML has a node in it that looks like this:

<lot id="ajhgkhga" lot="1" block="1" section="73R">

I need to change it to this (and retain the rest of the XML document):

<lot id="ajhgkhga" lot="1" block="22" section="55">

I have been hacking away at VBS most of the day and here is where I am now:

    Dim objXMLDoc
Dim objXMLElement
Dim objXMLNodeList
Dim numObjXMLNodeList
Dim i
Dim lot
Dim section
Dim attr


set objXMLDoc = CreateObject("Microsoft.XMLDOM")

objXMLDoc.async = "false"
objXMLDoc.load("section73R.xml")

Set objXMLNodeList = objXMLDoc.getElementsByTagName("lot")

numObjXMLNodeList = objXMLNodeList.length

For i = 0 to numObjXMLNodeList - 1

    ' current value of the block and section attributes of the lot element
    block = objXMLNodeList.item(i).getAttribute("block")
    section = objXMLNodeList.item(i).getAttribute("section")
    'Wscript.Echo block & " " & section

    ' new value of the block and section attributes of the lot element
    objXMLNodeList.item(i).setAttribute "block", "22"
    objXMLNodeList.item(i).setAttribute "section", "55"

Next

This throws an error as indicated above. My VBS chops are barely existent at this point, I have not done it in a very long time. The code above is designed only to try to read the attributes, I figured that once I had that replacing the values wouldn’t be too hard.

Can anyone help me actually figure out how to replace those values? And in doing so show me how far off I am in this script? Thanks in advance!

EDIT: I can now get the two attribute values out (see code change above). All I need now is a way to write the new attribute values to the XML file and this will be a done deal. Can anyone give me any pointers?

EDIT #2: I was able to solve it pretty quickly once I was able to retrieve the attribute values and I have edited the code above.

  • 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-06-02T23:49:49+00:00Added an answer on June 2, 2026 at 11:49 pm

    It’s unclear what the structure of your document is. I was able to change attributes using this code. Obviously, I don’t have multiple “lots” in my document so you may need to iterate through your nodes to find the one that you want to edit. This should get you going though:

    Dim oXML
    Set oXML = CreateObject("Microsoft.XMLDOM")
    oXML.loadXML("<list><lot id=""ajhgkhga"" lot=""1"" block=""1"" section=""73R""></lot></list>")
    
    Dim ixnLot
    Set ixnLot = oXML.selectSingleNode("//list/lot")
    ixnLot.Attributes.getNamedItem("block").Text = "22"
    ixnLot.Attributes.getNamedItem("section").Text = "55"
    
    'oXML.Save 'You'll need to call the same method to actually save the changes to the file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking all over the web for the simplest solution for this,
I have been reading all over the web about this and still can't understand
Hey all, I have been doing nothing but web development over the last few
I've been looking all over for a simple example of how to have an
I've been looking all over the web for a ColdFusion-based SQL administration tool for
I have been looking over the web but have not come across an answer
I desperately need help on this. I've have been looking all over for a
I have been looking at the feasibility of porting over an intranet web app
I've been all over the web trying to find a way to get VIM
I have been all over the web including Apple's dev site but I can't

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.