I will be glad to any help. How correctly to specify a way to an xml a file?
My application is crashing out of this code.
XDocument xDoc = XDocument.Load("XMLBase/Data.xml");
Sorry gyus. I will try to correct myself.
When testing the application through XamarinLive no problems.
After the application is archived and signed. I install the application (file .apk) on the phone. I launch the application on the phone. I turn to pages with a problem code and the application crashes.
Full page code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using System.Xml.Linq;
using Xamarin.Forms.Xaml;
namespace App14
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ListMain : ContentPage
{
public List<string> Students;
public ListMain ()
{
InitializeComponent ();
Students = new List<string>();
XDocument xDoc = XDocument.Load("XMLBase/Data.xml");
foreach (XElement xe in xDoc.Element("students").Elements("mainStudent"))
{
Students.Add(xe.Element("student").Value);
}
foreach (string student in Students)
{
stackLayout.Children.Add(new Label { Text = student, FontSize = 20, HorizontalOptions = LayoutOptions.StartAndExpand });
stackLayout.Children.Add(new Label { Text = "DEL", FontSize = 20, HorizontalOptions = LayoutOptions.End });
}
}
}
}