Hi again
I don't really get this yet. I'm trying to do all sort og things with XML using linq- and I have another question.
My XML looks something like this:
<?xml version="1.0" encoding="utf-8"?><UsersXX><User><User>kk1111aa</User><Product1>+</Product1><Product2>-</Product2></User><User><User>gg4455aa</User><Product1>+</Product1><Product2>-</Product2></User></UsersXX>
How do I check if a user input is equal to a child node in my XML?
Let's say I have a user input _user that I want to check. If it exists in my XML file, the user of the application should get message. If it do not exists it should call another function in my class.
I'm using linq, so I thought it was something like:
var checkUser = (from item in XDocument.Load(XMLLokation).Descendants("UsersXX") where item.Element("User").Value == (_user.ToLower()) select item); if (checkUser== null) { createToXML(); } if (addUser != null) { return MessageBox.Show("this user exists").ToString();
It does not work. I've checked a lot of different pages with questions about if statements in linq, but I can not get it to work :-(