I have a Xml file:-
<Users>
<User Name="abc" Pass="asp"></User>
<User Name="def" Pass="net"></User>
</Users>
I have to write a code where two user input values entered in the textbox eg:- usernm and pass are to be checked against the attribute of the particular node and its pass for returning a true value.
i want to check d inputs usernm and pass against the attribute name which if matches will check the pass as well and return a true of fasle value.
Please suggestsomething without using iterator and inumerable.
Well LINQ to XML is pretty much based on iterators, so it’s hard not to use them at all… but I suspect you want something like:
Or assign it to a variable:
or if you really want it as an
ifcondition:Personally I’d either extract this to a separate method (which can just be the return statement as per the first example) or use a local variable for simplicity – I don’t like my
ifconditions being this complicated.That will determine whether any
Userelement matches the relevant attributes. It doesn’t give any information about the element which matched, of course. For that you’d want to useFirstOrDefaultinstead ofAny, and then if the element is non-null, that’s the first match.