I have an XML like:
<Employee>
<Name> XXXX </Name>
<Address> YYYY </Addeess>
<Country> ZZZZ </Country>
</Employee>
How can i get the inner value of Country? Here Country is dynamically generated(based on user input).
It may be present or not. If present i need to fetch the inner value using c#.
This may help you :
XmlDocument ob = new XmlDocument();
ob.Load("yourxmlfile.xml");
XmlNodeList obj_country = ob.GetElementsByTagName("Country");
if(obj_country!= null)
{
string innertext_country_node = obj_country[0].InnerText;
}
var countryElement = XElement.Parse(xml).Element("Country");
string result = (countryElement != null) ? countryElement.Value : string.Empty;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.