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

  • Home
  • SEARCH
  • 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 8149829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:55:45+00:00 2026-06-06T14:55:45+00:00

I am creating a VB6 application, which reads information from an XML file and

  • 0

I am creating a VB6 application, which reads information from an XML file and then copies a particular file to my local workstation. The XML looks something like the below;

<ArrayOfMediaFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <MediaFile>
    <fileName>Default.jpg</fileName> 
    <filePath>C:\Program Files\media</filePath> 
    <dateModified>2012-04-30T14:41:28.6893988-05:00</dateModified> 
    <Action>Add</Action> 
  </MediaFile>
  <MediaFile>
    <fileName>icon.jpg</fileName> 
    <filePath>C:\Program Files\media</filePath> 
    <dateModified>2012-04-30T15:43:31.2995396-05:00</dateModified> 
    <Action>Add</Action> 
  </MediaFile>
</ArrayOfMediaFile>

Now my application reads the file name and if the action node is “add” it copies the file and converts the action node to “keep”.

The Problem

What i wish to do now is to save this file after every operation. If while saving the XML there is any error, I should be able to make a copy of the XML which I can again use in the operation.

  • 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-06T14:55:46+00:00Added an answer on June 6, 2026 at 2:55 pm

    This code always backs up the XML file .xml to .backup, and then if successful, it saves to _Processed.xml. Hope that’s what you want.

    Private Function ProcessFilesFromXml(ByRef the_sXmlFileName As String) As Boolean
    
        Dim nPosDot                         As Long
        Dim sXmlFileNamePrefix              As String
        Dim sXmlFileNameSuffix              As String
        Dim oXmlDoc                         As MSXML2.DOMDocument
        Dim oXmlMediaFileNode               As MSXML2.IXMLDOMElement
        Dim oXmlActionNode                  As MSXML2.IXMLDOMElement
    
        On Error GoTo ErrorHandler
    
        nPosDot = InStr(1, the_sXmlFileName, ".")
    
        If (nPosDot) Then
            sXmlFileNamePrefix = Left$(the_sXmlFileName, nPosDot - 1)
            sXmlFileNameSuffix = Mid$(the_sXmlFileName, nPosDot)
        Else
            sXmlFileNamePrefix = the_sXmlFileName
            sXmlFileNameSuffix = vbNullString
        End If
    
        ' First of all, back up the XML file <XmlFileList>.xml to <XmlFileList>.backup  . Overwrites existing backup file.
        FileCopy the_sXmlFileName, sXmlFileNamePrefix & ".backup"
    
        On Error GoTo ErrorHandler_ProcessingXml
    
        ' Load the Xml file <XmlFileList>.xml
        Set oXmlDoc = New MSXML2.DOMDocument
        oXmlDoc.Load the_sXmlFileName
    
        ' Iterate through each media file, and try to copy it.
        For Each oXmlMediaFileNode In oXmlDoc.selectNodes("/ArrayOfMediaFile/MediaFile")
            If Not CopyFileNameToLocalMachine(oXmlMediaFileNode.selectSingleNode("fileName").Text, oXmlMediaFileNode.selectSingleNode("filePath").Text) Then
                Set oXmlActionNode = oXmlMediaFileNode.selectSingleNode("Action")
                oXmlActionNode.Text = "keep"
            End If
        Next oXmlMediaFileNode
    
        ' Save under the name <XmlFileList>_Processed.xml
        oXmlDoc.save sXmlFileNamePrefix & "_Processed" & sXmlFileNameSuffix
    
        ' Since we got here, things must have been fine.
        ProcessFilesFromXml = True
    
    Return_ProcessingXml:
        '
    Exit Function
    
    ErrorHandler_ProcessingXml:
        ProcessFilesFromXml = False
        Resume Return_ProcessingXml
    
    ErrorHandler:
        Err.Raise Err.Number, Err.Source, Err.Description
    End Function
    
    Private Function CopyFileNameToLocalMachine(ByRef the_sFileName As String, ByRef the_sLocalPath As String)
        ' Your code here.
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok 2 questions here. I am creating a c# application from a vb6 application.
I have a VB6 application that is creating a JSON string and posting it
I am creating an installation package for a VB6 application using Visual Studio Installer
I'm creating an application in VB6, and I want to use my own cursors.
Can any one tell me how to convert an legacy application which is vb6
I have a legacy VB6 application that uploads file attachments to a database BLOB
We have a legacy VB6 application that uses Crystal Reports XI to generate printed
I'm creating a simple calculator on VB6. Here's my code I'm working on: textScreen.Text
I have a file in a Subversion repository which changes almost every time it's
So I'm creating a Activation class for a VB6 project and I've run into

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.