?
Solved

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

Posted on 2007-10-13
6
Medium Priority
?
541 Views
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>                  
<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" />
</Song>  

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

0
Comment
Question by:makman111
5 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20072895
Here is how you can read and add an attribute
http://www.functionx.com/vcsharp/xml/Lesson08.htm
0
 

Author Comment

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

Accepted Solution

by:
surajguptha earned 2000 total points
ID: 20074955
Ok here it is in VB .net
http://www.functionx.com/vbnet/xml/Lesson08.htm

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
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20295004
Forced accept.

Computer101
EE Admin
0
 

Expert Comment

by:irashkin
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.
thanks.
0

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