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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:51:16+00:00 2026-06-13T18:51:16+00:00

I need to delete an node in an XML, my XML looks as below

  • 0

I need to delete an node in an XML, my XML looks as below

<message_version>Test</message_version>
<responder_id>My test XML file</responder_id>
</m_control>
<m_content>
<b_control>
    <quote_response_status>error</quote_response_status>
    <quote_error_note>
        <reason>
            <note>
                <text>An error occurred.
                </text>
            </note>
        </reason>
    </quote_error_note>
</b_control>

In the above xml i need to remove the node “text” and “note”, keepimg the text “An error occurred.” untouched. How can i achieve that.

basically i need an XML as below after removing the node ‘text’ and ‘note’

<message_version>Test</message_version>
<responder_id>My test XML file</responder_id>
</m_control>
<m_content>
<b_control>
    <quote_response_status>error</quote_response_status>
    <quote_error_note>
        <reason>
            An error occurred.
        </reason>
    </quote_error_note>
</b_control>

I have tried the following with no sucess:

sXMLPath = "//message/m_content/b_control/quote_error_note/reason"
Set sRemoveText = m_objResponseXML.selectSingleNode(sXMLPath & "/note/text")
Set sRemoveNote = m_objResponseXML.selectSingleNode(sXMLPath & "/note")

If Not sRemoveText is Nothing Then
    m_objResponseXML.selectSingleNode(sXMLPath & "/note").removeChild(sRemoveText)
    sErrorMsg = GetNodeText(sXMLPath & "/note/text", m_objResponseXML)
End if
If Not sRemoveText is Nothing Then
    m_objResponseXML.selectSingleNode(sXMLPath).removeChild(sRemoveNote)
End If

If sErrorMsg <> "" Then
    m_objResponseXML.selectSingleNode(sXMLPath).text = sErrorMsg
End If

Any kind of help is deeply appreciated.

  • 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-13T18:51:17+00:00Added an answer on June 13, 2026 at 6:51 pm

    To examplify Rafael’s advice with code and to give you some search/keywords to look for when reading the Docs:

    Option Explicit
    
    Dim oXML : Set oXML = CreateObject("MSXML2.DomDocument")
    If oXML.load(".\005.xml") Then
       WScript.Echo oXML.xml
       Dim ndReason : Set ndReason = oXML.selectSingleNode("/b_control/quote_error_note/reason")
       If ndReason Is Nothing Then
          WScript.Echo "not reasonable"
       Else
          Dim sReason : sReason = ndReason.selectSingleNode("note/text").text
          ndReason.removeChild ndReason.firstChild
          WScript.Echo oXML.xml
          ndReason.appendChild oXML.createTextNode(sReason)
          WScript.Echo oXML.xml
       End If
    Else
       WScript.Echo oXML.parseError.reason
    End If
    

    output:

    cscript 005.vbs
    <b_control>
            <quote_response_status>error</quote_response_status>
            <quote_error_note>
                    <reason>
                            <note>
                                    <text>An error occurred.
                    </text>
                            </note>
                    </reason>
            </quote_error_note>
    </b_control>
    
    <b_control>
            <quote_response_status>error</quote_response_status>
            <quote_error_note>
                    <reason>
                    </reason>
            </quote_error_note>
    </b_control>
    
    <b_control>
            <quote_response_status>error</quote_response_status>
            <quote_error_note>
                    <reason>An error occurred.</reason>
            </quote_error_note>
    </b_control>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to delete a node in XML file using Javascript. The used browser
I need to delete a file. Occasionally, the file may be locked, in this
I need to delete specific employee node and also its child node based on
How can I delete a node from a BST? I need an algorithm to
I need to delete rows in a table, such as DELETE FROM TABLE_X WHERE
I need to delete all the folders in current directory that starts with say
I need to delete and erase object pointer on a vector. I see this
I need to delete a picture from a folder where pictures are stored. For
I need to delete a few fields from the table in the database. I
I need to delete a folder with contents using PHP. rmdir() and unlink() delete

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.