How do i obtain data from an xml file?
I have :
objXML = New DataSet
objXML.ReadXml(String.Concat(Global.ypPath, "\", GetExecutingAssembly.GetName.Name, ".xml"))
then
sServerName = objXML.ExtendedProperties.Item("config\SQLCatalog")
where my file has:
<config env="DEV">
<SQLCatalog>SQLD005C</SQLCatalog>
.....
.....
</config>
but sServerName is always empty
# 1 Re: How do i obtain data from an xml file?
Are you trying to read from the .config file. Then you don't need to open it using XML Reader. Just use something like this:
System.Configuration.ConfigurationSettings.AppSettings.Get("connectionString")
# 2 Re: How do i obtain data from an xml file?
The settings are in an XML file.
I have managed to figure it out
objXML = New XmlTextReader(String.Concat(Global.ypPath, "\", GetExecutingAssembly.GetName.Name, ".xml"))
objXML.WhitespaceHandling = WhitespaceHandling.None
While objXML.Read
If objXML.NodeType = XmlNodeType.Element Then
Select Case objXML.Name
Case "SQLCatalog"
sServerName = objXML.ReadString
Case "SQLDataSource"
sDataBase = objXML.ReadString
Case "DBUserId"
sUID = objXML.ReadString
Case "ENC_DBPassword"
sPWD = Decipher(objXML.ReadString)
End Select
End If
End While
objXML = Nothing
Thanks for persisting with me.