Это будет вопрос от c# новичка. Я хочу вывести файл json, который имеет путь в файле xml. Я не видел учебник по этому поводу. Может быть, кто-то может мне помочь? Вот мой код:
namespace Dev
{
class Program
{
static void Main(string[] args)
{
try
{
XElement element = XElement.Load(@"D:\\TUTORIALS- VIDEO\\C#\\Tasks\\config.xml");
List<Company> devices = new List<Company>();
foreach (XElement item in element.Elements())
{
Console.WriteLine(item);
}
}
catch (Exception e)
{
Console.WriteLine("The file could not be read.");
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
public class Company
{
public string jsonPathFileName { get; set; }
}
}
}
, который, кажется, не работает: - (
my xml: пример здесь, я хочу вывести company1. json.
<appConfig>
<Media>
<company>
<name>Company 1</name>
<id>1</id>
<jsonPathFileName>./company1.json</jsonPathFileName>
<apiUrl>http://demo.media.com/sp1</apiUrl>
<username>monitor</username>
<password>monitor</password>
</company>
<company>
<name>Company 2</name>
<id>1</id>
<jsonPathFileName>./company2.json</jsonPathFileName>
<apiUrl>http://demo.media.com/sp2</apiUrl>
<username>monitor</username>
<password>monitor</password>
</company>
</Media>
</appConfig>