.NET Linq TO XML 操作XML

2021-01-23 12:14

阅读:709

标签:class   from   def   val   element   hive   文档   hit   sel   

XML文档解析,使用Linq to Xml方式操作确实很方便,好东西值得推荐


    Models.AjaxResult.BlastSearchResult blastSearchResult = new Models.AjaxResult.BlastSearchResult();

    var rssXDoc = XDocument.Load(rtPath);

    blastSearchResult.Query = rssXDoc.Descendants("Iteration_query-def").FirstOrDefault().Value;
    blastSearchResult.Length = rssXDoc.Descendants("Iteration_query-len").FirstOrDefault().Value;
    blastSearchResult.Iteration_hits = new List();

    var queryHit = (from hit in rssXDoc.Descendants("Hit")
                    select new Models.AjaxResult.BlastSearchResult.Hit
                    {

                        Hit_num = hit.Element("Hit_num").Value,

                        Hit_id = hit.Element("Hit_id").Value, //Int32.Parse

                        Hit_def = hit.Element("Hit_def").Value,

                        Hit_accession = hit.Element("Hit_accession").Value,

                        Hit_len = hit.Element("Hit_len").Value,

                        Hit_hsps = Models.AjaxResult.BlastSearchResult.Hsp.ParserXmlNode(hit.Descendants("Hit_hsps"))

                    });

更详细的语法文档:linq to xml操作XML

.NET Linq TO XML 操作XML

标签:class   from   def   val   element   hive   文档   hit   sel   

原文地址:https://www.cnblogs.com/1ddd/p/13278149.html


评论


亲,登录后才可以留言!