Hi,

I'm creating a bookmarks system for my web browser. I'm learning how to use XML files with VB.Net, so my bookmarks are stored in an XML file. When I want to add a new bookmark, the code below works, but it only allows for one bookmark. How can I append to the XML file instead of overwriting it?

'It's not bookmarked, so let's add it
            Dim wtrXML As New XmlTextWriter(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Test" & "\" & "Bookmarks.xml", System.Text.Encoding.UTF8)
            With wtrXML
                .Formatting = Formatting.Indented
                .WriteStartDocument()
                .WriteStartElement("WebSites")
                .WriteStartElement("WebSite")
                .WriteElementString("Name", browser.Title)
                .WriteElementString("URL", tbaddress.Text)
                .WriteEndElement()
                .WriteEndElement()
                .WriteEndDocument()
                .Flush()
                .Close()
            End With

Thanks for your kind help,
JoThousand :)

Recommended Answers

Consider using something like an XmlDocument instead of using the writer directly. It'll be easier to do arbitrary things to your bookmark list with the XML DOM.

Jump to Post

All 2 Replies

Consider using something like an XmlDocument instead of using the writer directly. It'll be easier to do arbitrary things to your bookmark list with the XML DOM.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.