Jump to content
Xtreme .Net Talk

Recommended Posts

  • Administrators
Posted

Probably the best thing to do is decide if you wish to continue doing all the XML by hand, this will give you more control but create more work, or use something like Serialisation.

 

If you are moving away from the raw xml you could create your own collection class (or use generics -what version of VB are you using btw?) and simply store / calculate a unique numeric ID for each record.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Well I figured out how to iterate through the nodes and update the nodes I need updated.

 

This is the code I used to get it done......

 

 

 xmlDoc.Load(xmlFile)
       For Each myNode As XmlNode In xmlDoc.DocumentElement.ChildNodes
           If myNode.FirstChild.InnerText = lstNames.SelectedItem Then
               ' Updates xmlNode and its sibblings 
               Dim strName As String = txtName.Text
               Dim myArr() As String
               myArr = Split(strName, " ")
               strName = myArr(1) & ", " & myArr(0)
               myNode.FirstChild.InnerText = strName
               myNode.ChildNodes(1).InnerText = txtPhone.Text
               myNode.ChildNodes(2).InnerText = txtAddress.Text
               myNode.ChildNodes(3).InnerText = cboCity.Text
               myNode.ChildNodes(4).InnerText = txtState.Text
               myNode.ChildNodes(5).InnerText = txtZip.Text
               Dim strDates As New ArrayList
               Dim myString As String

               For Each itm As String In lstDates.Items
                   strDates.Add(itm)
               Next
               For i As Integer = 0 To strDates.Count - 1
                   myString &= strDates(i) & "\"
               Next
               myNode.ChildNodes(6).InnerText = myString 
               myNode.ChildNodes(7).InnerText = txtNote.Text


               xmlDoc.Save(xmlFile)

               Exit For
           End If
       Next



       xmlDoc = Nothing

 

It wasnt that hard after all.....

 

Want to say again thank all of you for this thread as it has really been an eye opener for me. I know I am only scratching the surface of xml but I am glad I started so Ill enjoy the learning as I go along...

 

vbMarkO

Visual Basic 2008 Express Edition!
  • 1 month later...
Posted

What a thread!

 

Hi,

 

Just wanted to say thanks and congratultations to the people who participated in this thread.

 

As I mentioned at the start of this thread, I know I don't get here as ofen as I should and I apologise for that but there are so many other things I need to do.

 

Anyway the point is I bought some book on XML programming at the same time as I started this thread. Which was like what vbMarkO had said, just an over view rather than real life examples. So when I found all the posts in this thread yesterday it was like an Aladin's cave. There is more information in the thread than in most of the book.

 

Thanks again and I have got this bookmarked in my browser.

 

Cheers, Dave.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...