• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4673
  • Last Modified:

Add nodes to a new xmldocument using vb.net

I have the following code below in which I am taking an rss feed and converting a section of it into a string.....

What I need to do...is take the node at each iteration of the For loop and add it back into a new xml.xmldocument....and then pass the full xml document to sqlserver adn store it as varchar I suppose...
not sure the best way to store it...but I need the entire xml file to be stored in one column of a database table.  My main concern is how to recreate the xml collection mentioned above....
Here is my code so far:


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGrab.Click

        Dim xmldoc As New Xml.XmlDocument
        Dim xmlnlist As Xml.XmlNodeList
        Dim xmln As Xml.XmlNode
        Dim xmlRevDoc As New Xml.XmlDocument

        Try
            Dim strURL As String = "http://feeds.feedburner.com/wnbc/sports"

            xmldoc.Load(strURL)
            xmlnlist = xmldoc.SelectNodes("//item/description")

            For Each xmln In xmlnlist
                Dim description = xmln.InnerText
                lblXML.Text += vbCrLf + description + vbCrLf + vbCrLf
            Next
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Sub
0
Robb Hill
Asked:
Robb Hill
1 Solution
 
ColemssCommented:
You should use a xmlDocument to do the work.

Maybe something like

element = xmlDocument.OwnerDocument.CreateElement(name)
element.InnerText = text;
parent.AppendChild(element);
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now