Imports System.IO Imports System.XML Public Class XML Public oXmlDocument As XmlDocument = New XmlDocument Public oXmlNameSpaceManager As XmlNamespaceManager Public oXmlNodeList As XmlNodeList Public oXmlNode As XmlNode Public oXmlElement As XmlElement Public cNodeInnerText As String = "" Public cXmlNameSpaceManager As String = "" Public cXmlNameSpaceManagerPrefix As String = "" Public cXML As String = "" Public cAttachment As String = "" ' Get a XML node value ' expC1 XML ' expC2 Node Public Function GetXMLNodeValue(ByVal tcXML As String, ByVal tcNode As String) As Boolean Dim llSuccess As Boolean oXmlDocument.LoadXml(tcXML) ' If we have a namespace If cXmlNameSpaceManager.Length > 0 Then oXmlNameSpaceManager = New XmlNamespaceManager(oXmlDocument.NameTable) oXmlNameSpaceManager.AddNamespace(cXmlNameSpaceManagerPrefix, cXmlNameSpaceManager) End If ' Select the node If cXmlNameSpaceManager.Length = 0 Then oXmlNode = oXmlDocument.SelectSingleNode(tcNode) Else oXmlNode = oXmlDocument.SelectSingleNode(tcNode, oXmlNameSpaceManager) End If ' See if we obtained the node If oXmlNode Is Nothing Then Framework.App.cError = "The node " + tcNode + " does not exist." Return False End If Try cNodeInnerText = oXmlNode.InnerText llSuccess = True Catch loError As Exception Framework.App.ErrorSetup(loError) End Try Return llSuccess End Function End ClasscXmlNameSpaceManagerPrefix has been added to the class. I can assign the value externally and can also decide on the global declaration on how it should be called.
loXML.cXmlNameSpaceManager = "http://www.mywebsite.com/services/core/transformation/transformationresults" loXML.cXmlNameSpaceManagerPrefix = "ns" If loXML.GetXMLNodeValue(lcXML, "//ns:TransformationResults/ns:FileTransformationResults/ns:OutputFile") = False Then lcHTML = lcHTML + "<TD ALIGN=RIGHT>" + Math.Round(((lnEnd - lnStart) / 10000000), 2).ToString("#0.00") lcHTML = lcHTML + "<TD>Success with failure on renaming the file: " + Framework.App.cError cHtml = lcHTML Return False End If