Hello guys, I am trying to invoke a code like this:
if (File.Exists(in_rutaArchivoXML))
{
// reads .xaml as string
string solicitudesXamlText = File.ReadAllText(in_rutaArchivoXML);
// creates new XmlDocument object
XmlDocument solicitudesXML = new XmlDocument();
// loads the doc
solicitudesXML.LoadXml(solicitudesXamlText);
// list of nodes /descargaSolicitudesEESS/solicitudRecibidaEESS
XmlNodeList xnList = solicitudesXML.SelectNodes("/descargaSolicitudesEESS/solicitudRecibidaEESS");
// iterate through list
foreach (XmlNode xn in xnList)
{
string nroOperacion = xn["nroOperacion"].InnerText;
out_nrosOper.Add(nroOperacion);
}
}
What I am trying to achieve is to read a xml document whose file path is in_rutaArchivoXML
(one of my Invoke Code arguments) and obtain a list of values which is out_nrosOper - List<string>
(my second argument) but I am getting an error which says "Invoke code: Exception has been thrown by the target of an invocation."
Any hint would be great. Also I share my original C# function code (which gets me what I need using Visual Studio)
public static List<string>? ObtenerNrsOper(string rutaArchivoXML)
{
List<string> nrosOperacion = new List<string>();
if (File.Exists(rutaArchivoXML))
{
// lee .xaml como texto
string solicitudesXamlText = File.ReadAllText(rutaArchivoXML);
// crear nuevo objeto XmlDocument
XmlDocument solicitudesXML = new XmlDocument();
// carga el documento Xml
solicitudesXML.LoadXml(solicitudesXamlText);
// lista de nodos /descargaSolicitudesEESS/solicitudRecibidaEESS
XmlNodeList? xnList = solicitudesXML.SelectNodes("/descargaSolicitudesEESS/solicitudRecibidaEESS");
if (xnList is not null)
{
// iterar por lista de nodos
foreach (XmlNode xn in xnList)
{
if (xn is not null)
{
string nroOperacion = xn["nroOperacion"].InnerText;
nrosOperacion.Add(nroOperacion);
Console.WriteLine(nroOperacion);
}
}
}
Console.WriteLine("finalizado");
return nrosOperacion;
}
return null;
}