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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:08:18+00:00 2026-05-30T10:08:18+00:00

I just want to know how to add a button that has a removechild()

  • 0

I just want to know how to add a button that has a removechild() or replacechild() function on my XML. Been searching for this for a week now.

Any suggestions would be greatly appreciated. Thanks 🙂

This is my xml file content

 <?xml version="1.0" encoding="utf-8"?>
 <theNews>
 <news>
 <contents>News3 Contents</contents>
 <title>News3 Title</title>
 <pubDate>February 13, 2012</pubDate>
 </news>
 <news>
 <contents>News2 Contents</contents>
 <title>News2 Title</title>
 <pubDate>February 1, 2012</pubDate>
 </news>
 <news>
 <contents>News1 Contents</contents>
 <title>News1 Title</title>
 <pubDate>January 22, 2012</pubDate>
 </news>
 </theNews>

This is the code for my News Updater

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="NewsUpdater.aspx.vb" Inherits="NewsUpdater" %>

 <%-- Add content controls here --%><asp:Content ID="Content1" runat="server" 
contentplaceholderid="ContentPlaceHolder1">

        <p>
            &nbsp;</p>
        <table align="center" style="width: 63%">
            <tr>
                <td align=center>
                    <div>
    <h3>News Title</h3>
    <asp:TextBox runat="server" ID="txtTitle" Width="308px"></asp:TextBox>
                        <br />
    <h3>News Content</h3>
    <asp:TextBox runat="server" ID="txtContents" TextMode="MultiLine" Height="119px" Width="513px"></asp:TextBox>


                        <br />

                        <br />
                        <asp:Button ID="Button1" runat="server" Text="Update News" />
</div></td>
            </tr>
        </table>
        <p>
            <br />
        </p>

And this is the code behind the NewsUpdater button

 Partial Class NewsUpdater
 Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim xmlFile As New System.Xml.XmlDocument()
    xmlFile.Load("D:\My Documents\PresentableII\NewsContent.xml")

    Dim theNewsTag As System.Xml.XmlElement = xmlFile.CreateElement("news")
    Dim theTitleTag As System.Xml.XmlElement = xmlFile.CreateElement("title")
    Dim theContentsTag As System.Xml.XmlElement = xmlFile.CreateElement("contents")

    Dim theTitleText As System.Xml.XmlText = xmlFile.CreateTextNode(txtTitle.Text)
    Dim theContentsText As System.Xml.XmlText = xmlFile.CreateTextNode(txtContents.Text)

    theTitleTag.PrependChild(theTitleText)
    theContentsTag.PrependChild(theContentsText)


    theNewsTag.PrependChild(theTitleTag)
    theNewsTag.PrependChild(theContentsTag)

    xmlFile.DocumentElement.PrependChild(theNewsTag)
    xmlFile.Save("D:\My Documents\PresentableII\NewsContent.xml")

    Response.Redirect("NewsFrame.aspx")

End Sub

I want to add another button that has a function of remove or replace the last/latest entry to the xml.

  • 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-30T10:08:20+00:00Added an answer on May 30, 2026 at 10:08 am

    So would this line do what you want?

    xmlFile.DocumentElement.RemoveChild(xmlFile.DocumentElement.LastChild)
    xmlFile.DocumentElement.AppendChild(your_replacement_element)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just want to know if there other optional wrapper framework available that generate client
I just want to know if there is a program that can convert an
i just want to know a general information about this particular information. Any good
I just want to know why this doesn't work (I am trying to name
I want to add views on click of button. My screen has a text
I know, this has been asked a few times, but mostly for Xcode 3.x.
I'm using the Twenty-Ten theme and just want to know whether the indent button
Just want to know how to read an attribute of a parent node from
I just want to know: How can I delete 'log.txt' if the last modification
I just want to know how does the table resulting from readXML look like,

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.