How to get info from xaml file in C#

A N 81 Reputation points
2020-12-01T01:25:52.857+00:00

Hello. In my C# program I want to know how to read this file:

<!-- Info.xaml -->
<Credentials Username="UsernameHere" Password="PasswordHere"/>

and get the Username's value and put it in a string, how can I do this?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,908 questions
{count} votes

Accepted answer
  1. Cheong00 3,476 Reputation points
    2020-12-01T02:54:09.983+00:00

    Just read it as XML file, then use .GetElementsByTagsName("Credentials") to select Credentials nodes and read the Username attribute of first element by [0].Attribute["Username"].Value .

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.