How to read a tag inside another xml tag?
Example:
<site id = "1" clas = "black"><test> Value </test></site>
I want to read the test tag inside <site>
. I want to return what's inside it.
My code:
XmlReader xmlReader = XmlReader.Create("site.xml");
while (xmlReader.Read())
{
if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "site"))
{
if (xmlReader.HasAttributes)
{
string test = xmlReader.GetAttribute("id");
Console.WriteLine(test);
}
}
}