I am using a StreamReader
to read a XML file.
From that, how to get particular content in the file?
C# code I'm using:
using (StreamReader streamreader = new StreamReader(inputxmlfile))
{
string doc = streamreader.ReadLine();
while (doc != null)
{
if (content.Contains("sxnum"))
{
// How to get the 'sxnum' attribute value?
}
doc = streamreader.ReadLine();
}
}
Here what the XML file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd nominee ="1 2 First" sxnum="63828910">
<title company="Grammy" price="10.20">1999 Grammy Nominees</title>
<artist all="type">Many</artist>
<country>USA</country>
.....
</catalog>
The desired output in this case is:
63828910