We help IT Professionals succeed at work.

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

557 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

Comment
Watch Question

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

Author

Commented:
Nope - that is c# and does not really describe what I need to do.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Forced accept.

Computer101
EE Admin

Commented:
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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.