LINQ to xml使用VB.Net语法错误

时间:2017-01-06 02:50:03

标签: xml vb.net linq

我对VB.Net更新。当我转换为VB时,我有C#代码,它显示语法错误为')'预计在这一行上:" _IndustryList =(来自行业xDoc.Root.Elements("记录")新行业()"  请帮我指出错误。 我用过在线转换器。 或者是否有任何其他方法来查询xml文件。感谢

http-client

1 个答案:

答案 0 :(得分:0)

试试这个

                        _IndustryList = xDoc.Root.Elements("record").Select(Function(industry) New Industry() With { _
                                                                           .IndName = CType(industry.Element("Industry"), String), _
                                                                           .NAICS = CType(industry.Element("NAICS"), Integer), _
                                                                           .Classification = CType(industry.Element("Classification"), String), _
                                                                           .IBCCode = CType(industry.Element("IBCCode"), String), _
                                                                           .Notes = CType(industry.Element("Notes"), String) _
                                                                       }).ToList()