Hi,
I’ve made a class to help me accomplish some things faster but I’m having
problems inserting nodes. I’ve tried many different ways, but with no
success. This is a very stripped down version of what I’m trying to do. I
know that I’m simply missing some basic understanding, so hopefully someone
can enlighten me.
Public Class MYXMLCLASS
Public theXMLDocument As New XmlDataDocument
Public myXPath As String
Sub New()
myXPath = "/"
Exit Sub
End Sub
Public Function addDeclaration( ) As String
Dim myDeclaration As XmlDeclaration
myDeclaration = theXMLDocument. CreateXmlDeclar ation("1.0", Nothing,
Nothing)
myDeclaration = theXMLDocument. InsertBefore(my Declaration,_
theXMLDocument. DocumentElement )
lastNode = CType(myDeclara tion, XmlNode)
Return True
End Function
Public Function addNode(ByVal myXMLString As String) As String
Dim myNewDoc As New XmlDataDocument
Dim myReturnNode As XmlNode
Dim myCurrentNode As XmlNode =
theXMLDocument. SelectSingleNod e(myXPath)
myNewDoc.LoadXm l(myXMLString)
myReturnNode = theXMLDocument. DocumentElement .InsertAfter(my NewDoc,_
myCurrentNode)
Return myCurrentNode.O uterXml
End Function
This is called in another place
Dim myPageInfoXML As New MYXMLCLASS
myPageInfoXML.s etPath("/") // sets myXPath
myPageInfoXML.a ddDeclaration()
myPageInfoXML.a ddNode("<test>b lah</test>")