troubleshooting Question

Code to insert an XML line VB.NET 2005

Avatar of arthurh88
arthurh88 asked on
.NET ProgrammingASP.NETVisual Basic.NET
4 Comments1 Solution1665 ViewsLast Modified:
Here is my sample XML file
  <total_loops value="0" />
  <total_cmds value="0" />
  <total_macros value="5" />
  <loop1 name="MyLoop1" type="Min" length="20" data="Sample XML File" />
  <loop2 name="MyLoop2" type="Sec" length="50" data="some more data" />
  <macro1 name ="My Macro" Value ="100-245,C,W1,200-340,DC" />

Im trying to get this function to work in order to insert a new nodelist after any particular nodename

Public Function InsertNode(ByVal FilePath As String, ByVal NodeXML As String, byVal AfterThisNode as string) As Boolean
        Dim doc As New System.Xml.XmlDocument
        Dim nd As System.Xml.XmlNode
        nd = doc.DocumentElement.GetElementsByTagName(AfterThisNode).Item(0)
        If nd Is Nothing Then 'could not find the node to insert after, then just add to the bottom
        'TO DO:  need code to add the line of XML to the end of the document
        ELSE 'found the node, now insert new line after
        TO DO:  need code to insert XML line after found node
        End If
        Return True
    End Function

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros