Visual Basic 2005 newb in need of some XML write to file help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jgibbens
    New Member
    • Feb 2008
    • 1

    Visual Basic 2005 newb in need of some XML write to file help

    First, thank you for even looking at my question.

    I am using VB 2005 and I have a question about XML.


    what I want to do is:
    1. keep adding to this file with out over writing it
    2. be able to change stuff the XML without overwriting the rest of the file

    This is the XML I have:
    [code=html]
    <presentation courseName="" lesson="">
    <modules>
    <module>
    <title hide=""></title>
    <imageLoc url=""></imageLoc>
    <bullets>
    <bullet></bullet>
    </bullets>
    <bdyhtmlText>wo rker</bdyhtmlText>
    <checkPoint hide="">
    <question></question>
    <answers>
    <answer resp=""></answer>
    <correctAnswer> </correctAnswer>
    </answers>
    </checkPoint>
    </module>
    </modules>
    </presentation>
    [/code]

    I have this code that writes the initial XML:
    [code=vbnet]
    Public Class Form1

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

    End Sub

    Private Sub SaveToolStripMe nuItem_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles SaveToolStripMe nuItem.Click

    Dim setting As Xml.XmlWriterSe ttings = New Xml.XmlWriterSe ttings()
    setting.Indent = True
    setting.NewLine OnAttributes = True
    Dim xw As Xml.XmlWriter = Xml.XmlWriter.C reate("C:\Docum ents and Settings\gibben sj\Desktop\new writer test feb 20 2008\WindowsApp lication1\books .xml", setting)
    xw.WriteStartDo cument()
    xw.WriteStartEl ement("presenta tion")
    xw.WriteStartEl ement("modules" )
    xw.WriteStartEl ement("module")
    xw.WriteElement String("title", titleBx.Text)
    xw.WriteElement String("imageLo c", slideBx.Text)
    xw.WriteStartEl ement("bullets" )
    xw.WriteElement String("bullet" , "")
    xw.WriteEndElem ent()
    xw.WriteElement String("bdyhtml Text", bodyBx.Text)
    xw.WriteStartEl ement("checkpoi nt")
    xw.WriteEndElem ent()
    xw.WriteEndElem ent()
    xw.WriteEndElem ent()
    xw.WriteEndDocu ment()
    xw.Flush()
    xw.Close()
    End Sub
    End Class
    [/code]

    How would I go about this?

    I am loving VB but it is very difficult. My hats off to those of you who are productive with it. Thank you for any help, in advance.

    -J
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .net forum.

    Comment

    Working...