Member Avatar for iamthwee


I need some help with this one. Ok, I want to create an xml file of all my mp3 files on my home pc.:S

I am using the code as follows:-

Public Class Form1
  Dim myWriter As New System.Xml.XmlTextWriter
  myWriter = New System.Xml.XmlTextWriter("C:\music_stuff.xml", Nothing)
 With myWriter
      .Indentation = 4
      .IndentChar = " "
      .Formatting = . Indentation
      .WriteComment ("my freaking music yay")
      .WriteElementString("title","blah blah")
      .WriteElementString("description", "wah wah wah")
 End With
End Class

It gives output something like:-

<?xml version="1.0" ?>
  <!-- my freaking music yay -->
     <description>wah wah wah</description>

And that just works fine for one record, but I want to append to this one file all my mp3s. But I just don't know how to append, well I have an idea but it is long winded. What's gonna be the best way?

Member Avatar for iamthwee

No one can help me :(

Member Avatar for Dukane

Hmm...I don't remember if there is a specific way to do it with the code and the objects themselves.

But, in theory, could you read whatever is in the document into a variable, then create the new data and then write it all back in one huge chunk at the end?

Member Avatar for iamthwee

Anyone else?

Member Avatar for iamthwee

I was googling before and came across that same link. But it didn't really help me. I didn't think appending an xml file would be so hard.

Argh, I might even have to write my own api.

Be a part of the DaniWeb community

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