将 xml 标记与文本框进行比较
本文关键字:比较 文本 xml | 更新日期: 2023-09-27 18:30:38
我想读取我的xml,如果文本框中的文本与xml中的标记相同,我希望它导航到其他页面。
我的代码是:
StorageFolder storageFolder = Package.Current.InstalledLocation;
StorageFile storageFile = await storageFolder.GetFileAsync("Registeduser.xml");
string xml = await FileIO.ReadTextAsync(storageFile, Windows.Storage.Streams.UnicodeEncoding.Utf8);
var doc = XDocument.Parse(xml);
StorageFolder pastaxml = Package.Current.InstalledLocation;
pastaxml = await pastaxml.GetFolderAsync("users''1101046102''xml''");
StorageFile login = await pastaxml.GetFileAsync("info.xml");
string xmllogin = await FileIO.ReadTextAsync(login, Windows.Storage.Streams.UnicodeEncoding.Utf8);
var xdoc = XDocument.Parse(xmllogin);
var rootemail = xdoc.Root;
var rootNode = doc.Root;
foreach (var child in rootNode.Descendants("user"))
{
//Login is a class
var objLogin = new Login
{
id = child.Element("id").Value,
Email=child.Element("email").Value
};
}
foreach (var logemail in rootemail.Descendants("info"))
{
//Info is a class
var email = new Info
{
Email = logemail.Element("email").Value
};
Info info = new Info();
if (txtemail.Text == info.Email.ToString())
{
this.Frame.Navigate(typeof(DashBoard));
}
else
{
MessageBox("Email ou password incorreta");
}
}
XML是:
<info>
<id>1101046102</id>
<email>email@hotmail.com</email>
</info>
和:
<?xml version="1.0" encoding="utf-8" ?>
<registeredUser>
<user>
<id>1101046102</id>
<email>email@hotmail.com</email>
</user>
</registeredUser>
我想要的只是将registeduser中的电子邮件与info.xml中的电子邮件进行比较.xml。当我取消程序并单击进入下一页时,该程序不执行任何操作。我做错了什么?
我想要的只是将注册用户中的电子邮件与信息中的电子邮件进行比较.xml.xml
bool isEqual = doc.Descendants("email").First().Value ==
xdoc.Descendants("email").First().Value;