How to Read XML tag values in C# [duplicate]




This question already has an answer here:




I have an XML file like below:



<sections>
<section name="516604">
<item key="Terminal" value="254726387322" />
<item key="UserName" value="SomeName" />
<item key="Pass" value="XXXX" />
</section>
<section name="802200">
<item key="Terminal" value="254726402010" />
<item key="UserName" value="SomeOtherName" />
<item key="Pass" value="XXXX" />
</section>
</sections>


How can I have a C# function that returns a string containing a field value like below:



public string GetXMLValue(string Section, string Terminal)
{
return string TerminalOfSection
}


The above method should return the XML Tag value "Terminal" of a given Section say "516604" as a string.


Thank You.


No comments:

Post a Comment