简体   繁体   中英

How to get value of a specific element in xml in c#

I have a xml file in below format

I want to fetch the value of Child1 When I am using below code it is providing a null value. Please help

XDocument xmlDoc = XDocument.Load(fileName);
 XElement po = xmlDoc.Root.Element("Root");
 XElement el1 = po.Element("Child1");

用这个:

xmlDoc.Descendants("Child1").First();

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM