edwbear1976a
asked on
using relative or absolute url or maybe sever.mapppath when I'm developing or publishing to load an xml file
HI Guys:
I'm developing a web proyect and the connection string is in a label in a xml page.. I kow how to handle it but when I use the method Load(Url) I have a doubt.. that's why I run the web app proyect from my VEstudio IDe virtual server that is not the same when I have to publish for internet purposes.
this is the code that I use for development pursposes
/*
try
{
XmlDocument oTagDocumento = new XmlDocument();
oTagDocumento.Load(_UrlFil e);
XmlNodeList oTagConexiones = oTagDocumento.GetElementsB yTagName(" CONECCIONE S");
XmlNodeList oTagListaConexion = ((XmlElement)oTagConexione s[0]).GetE lementsByT agName("CO NECCION");
foreach (XmlElement nodo in oTagListaConexion)
{
int i = 0;
XmlNodeList olstLlave = nodo.GetElementsByTagName( "LLAVE");
XmlNodeList olstValor = nodo.GetElementsByTagName( "VALOR");
if (olstLlave[i].InnerText == _NombreEtiquetaLlave)
{
sResultado = sResultado + olstLlave[i].InnerText.ToS tring() + olstValor[i].InnerText.ToS tring();
break;
}
}
}
catch (System.IO.FileNotFoundExc eption e)
{
sResultado = e.Message;
}
catch (Exception e)
{
sResultado = sResultado + e.Message;
}
*/
Where the url is absolute path, but what about when I publish it, I want to use the same relative/absolute path on developping time or when I publish it. Maybe I have to use the Server.MappPath method but HOw?
I'm developing a web proyect and the connection string is in a label in a xml page.. I kow how to handle it but when I use the method Load(Url) I have a doubt.. that's why I run the web app proyect from my VEstudio IDe virtual server that is not the same when I have to publish for internet purposes.
this is the code that I use for development pursposes
/*
try
{
XmlDocument oTagDocumento = new XmlDocument();
oTagDocumento.Load(_UrlFil
XmlNodeList oTagConexiones = oTagDocumento.GetElementsB
XmlNodeList oTagListaConexion = ((XmlElement)oTagConexione
foreach (XmlElement nodo in oTagListaConexion)
{
int i = 0;
XmlNodeList olstLlave = nodo.GetElementsByTagName(
XmlNodeList olstValor = nodo.GetElementsByTagName(
if (olstLlave[i].InnerText == _NombreEtiquetaLlave)
{
sResultado = sResultado + olstLlave[i].InnerText.ToS
break;
}
}
}
catch (System.IO.FileNotFoundExc
{
sResultado = e.Message;
}
catch (Exception e)
{
sResultado = sResultado + e.Message;
}
*/
Where the url is absolute path, but what about when I publish it, I want to use the same relative/absolute path on developping time or when I publish it. Maybe I have to use the Server.MappPath method but HOw?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Sara. I've been trying to use the ConfigurationManager class but I couldn't find it. what super class does it belong? do I have to importe or use some class spaces?
ConfigurationManager is a class from System.Configuration namespace (and System.Configuration.dll).
It is a new class in .NET 2.0 so if you are working on a .NET 1.1 project then you should use old classes to read from application configuration file.
It is a new class in .NET 2.0 so if you are working on a .NET 1.1 project then you should use old classes to read from application configuration file.
ASKER
Okey, Saaa, I just found it . I added the reference System.Configurarion to my proyect and then I impotted it and it worked GREAT!!!!!
Thanx so much!!!!
Thanx so much!!!!
ASKER
well Ithe UrlFile that I load is about the db connection string.. looking at this code I think that this might be usefull, Let me try it tomorrow, I feel this is going to work.