D
Dave
I am trying to run a fucntion to add and format the final XML message.
I tried passing the NodeBody to the Function (like I would have done
with VB6) but a scope error.
What's the best way to do this?
Thanks
Main Code:
------------------
Dim objXML As New Xml.XmlDocument
Dim nodeBody As Xml.XmlNode
Dim nodeTest1 As Xml.XmlNode
Dim nodeTest2 As Xml.XmlNode
nodeBody = objXML.CreateNode(XmlNodeType.Element, "Body", "")
nodeTest1 = objXML.CreateElement("TestValue1")
nodeTest2 = objXML.CreateElement("TestValue2")
nodeTest1.InnerText = "ActualValue1"
nodeTest2.InnerText = "ActualValue2"
nodeBody.AppendChild(nodeTest1)
nodeBody.AppendChild(nodeTest2)
objXML.AppendChild(nodeBody)
Dim xmlDave As New Xml.XmlDocument
xmlDave = AddXMLHeader(nodebody, "Test.XML", "TestXMLMessage")
Class Code:
-----------------
Public Function AddXMLHeader(ByVal nodePassed As Xml.XmlNode, ByVal
strFileName As String, ByVal strNodeName As String) As Xml.XmlDocument
'This procedure will add a header and the main body of the XML
message.
'
Dim xmlTemp As New Xml.XmlDocument
Dim nodeHeader As Xml.XmlNode
Dim nodeTimeStamp As Xml.XmlNode
Dim nodeFileName As Xml.XmlNode
Dim nodeWrite As Xml.XmlNode
nodeHeader = xmlTemp.CreateNode(Xml.XmlNodeType.Element, "Header",
"")
nodeTimeStamp = xmlTemp.CreateNode(Xml.XmlNodeType.Element,
"TimeStamp", "")
nodeFileName = xmlTemp.CreateNode(Xml.XmlNodeType.Element,
"FileName", "")
nodeWrite = xmlTemp.CreateNode(Xml.XmlNodeType.Element,
strNodeName, "")
nodeTimeStamp.InnerText = Now
nodeFileName.InnerText = strFileName
nodeHeader.AppendChild(nodeTimeStamp)
nodeHeader.AppendChild(nodeFileName)
nodeWrite.AppendChild(nodeHeader)
nodeWrite.AppendChild(nodePassed) <<<<<<<<<<<<<<<<<<<
xmlTemp.AppendChild(nodeWrite)
Return xmlTemp
End Function
I tried passing the NodeBody to the Function (like I would have done
with VB6) but a scope error.
What's the best way to do this?
Thanks
Main Code:
------------------
Dim objXML As New Xml.XmlDocument
Dim nodeBody As Xml.XmlNode
Dim nodeTest1 As Xml.XmlNode
Dim nodeTest2 As Xml.XmlNode
nodeBody = objXML.CreateNode(XmlNodeType.Element, "Body", "")
nodeTest1 = objXML.CreateElement("TestValue1")
nodeTest2 = objXML.CreateElement("TestValue2")
nodeTest1.InnerText = "ActualValue1"
nodeTest2.InnerText = "ActualValue2"
nodeBody.AppendChild(nodeTest1)
nodeBody.AppendChild(nodeTest2)
objXML.AppendChild(nodeBody)
Dim xmlDave As New Xml.XmlDocument
xmlDave = AddXMLHeader(nodebody, "Test.XML", "TestXMLMessage")
Class Code:
-----------------
Public Function AddXMLHeader(ByVal nodePassed As Xml.XmlNode, ByVal
strFileName As String, ByVal strNodeName As String) As Xml.XmlDocument
'This procedure will add a header and the main body of the XML
message.
'
Dim xmlTemp As New Xml.XmlDocument
Dim nodeHeader As Xml.XmlNode
Dim nodeTimeStamp As Xml.XmlNode
Dim nodeFileName As Xml.XmlNode
Dim nodeWrite As Xml.XmlNode
nodeHeader = xmlTemp.CreateNode(Xml.XmlNodeType.Element, "Header",
"")
nodeTimeStamp = xmlTemp.CreateNode(Xml.XmlNodeType.Element,
"TimeStamp", "")
nodeFileName = xmlTemp.CreateNode(Xml.XmlNodeType.Element,
"FileName", "")
nodeWrite = xmlTemp.CreateNode(Xml.XmlNodeType.Element,
strNodeName, "")
nodeTimeStamp.InnerText = Now
nodeFileName.InnerText = strFileName
nodeHeader.AppendChild(nodeTimeStamp)
nodeHeader.AppendChild(nodeFileName)
nodeWrite.AppendChild(nodeHeader)
nodeWrite.AppendChild(nodePassed) <<<<<<<<<<<<<<<<<<<
xmlTemp.AppendChild(nodeWrite)
Return xmlTemp
End Function