Read only parts of an XML file

后端 未结 3 490
醉梦人生
醉梦人生 2021-01-29 14:31

 
  RadheyJang 
  India 
  Software Developer 
  

        
3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-29 14:41

    You need to use XPath for this...

    using System.Xml.XPath;
    
    string xml = @"
        
            
            RadheyJang 
            India 
            Software Developer 
            5 
            
    ArunaTiwari India SoFtwareCoder 3
    A
    NA
    "; XDocument xmlDoc = XDocument.Parse(xml); var vrresult = from a in xmlDoc.XPathSelectElements("/Peoples/People") select new { Name = a.Element("Name").Value, Location = a.Element("Location").Value, Point = a.Element("Point").Value };

提交回复
热议问题