VB.NET 2005: Modify XML document with data from a tab delimited text file.

Posted on 2007-10-13
Medium Priority
Last Modified: 2013-11-26
I want to take data from a tab delimited text file and use it to update (or append) a property in an XML node (using vb.net 2005).  The xml file has the following structure:

<Song FilePath="V:\Music\Bob Dylan\Various\Highway 51.mp3" FileSize="2764199">
  <Display Author="Bob Dylan" Title="Highway 51" Genre="Rock" Album="Various" Year="1986" Color="16144387" Cover="2" Tag="1" />
  <Infos FirstSeen="709211425" Key="E m" />
  <BPM Bpm="19995" />
<Song FilePath="V:\Music\Eminem\The Eminem Show\07 Soldier.mp3" FileSize="4548319">
  <Display Author="Eminem" Title="Soldier" Genre="Hip Hop/Rap" Album="The Eminem Show" Year="2002" Color="5285822" Cover="1" Tag="1" />
  <Infos FirstSeen="709211425" />
  <BPM Bpm="28148" />

On the Song/Infos node there is a Key property.  I want to update that property from the text file (sample below).  If the Song/Infos node does not have a key property I need to add the property to the Song/Infos node.  I would locate the correct node by comparing the Filepath property on the Song node.  I would only update information in the XML file that exists in the text file.  If there is no text file enrty for a node, skip it - no changes.

The tab delimited file looks like this:

FilePath (misc info) (misc info) (misc info) (misc info) (misc info) (misc info) Key

Question by:makman111
LVL 21

Expert Comment

ID: 20072895
Here is how you can read and add an attribute

Author Comment

ID: 20074804
Nope - that is c# and does not really describe what I need to do.
LVL 21

Accepted Solution

surajguptha earned 2000 total points
ID: 20074955
Ok here it is in VB .net

Why do you think this doesnt describe what you need to do?
From my understanding you are looking to see if a attribute by name key property exists, if it doesnt add it. The link explains how to read an attribute and add one.

Correct me if my understanding is wrong

Expert Comment

ID: 20295004
Forced accept.

EE Admin

Expert Comment

ID: 21402738
I know this is closed, but it seems to me that the question was not answered - at least not my interpretation of it. The answer tells how to add an attribute to an existing xml document, but if I am reading correctly, makman111 was trying to EDIT an exiting attribute in an existing xml document. Of course there are lots of ways to do this but it seems to be not as simple as adding. I am still looking for the simplest way to do this, which is why I was hoping this post was going to lead somewhere more informative. If I am misunderstanding the original question, then I suppose this is a new question - maybe makman111 can confirm if this is what he was asking or not.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question