C# 如何为更多名称空间的字符串数组分配属性名
我必须将名称空间thredds的name属性设置为字符串数组。我需要将文件名设置为数组(thredds:dataset name)。 我尝试了C# 如何为更多名称空间的字符串数组分配属性名,c#,xml,C#,Xml,我必须将名称空间thredds的name属性设置为字符串数组。我需要将文件名设置为数组(thredds:dataset name)。 我尝试了doc.Root.Elements()选择dataset并 var names = rows.Select(o => (string)o.Element("name")).ToArray(); 但是不起作用。请建议我。xml是这样的 <thredds:catalog xmlns:thredds="http://www.unidata.uca
doc.Root.Elements()选择dataset
并
var
names = rows.Select(o => (string)o.Element("name")).ToArray();
但是不起作用。请建议我。xml是这样的
<thredds:catalog xmlns:thredds="http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:bes="http://xml.opendap.org/ns/bes/1.0#">
<thredds:service name="dap" serviceType="OPeNDAP" base="/opendap/hyrax"/>
<thredds:service name="file" serviceType="HTTPServer" base="/opendap/hyrax"/>
<thredds:service name="wms" serviceType="WMS" base="/ncWMS/wms"/>
<thredds:dataset name="/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014" ID="/opendap/hyrax/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/">
<thredds:dataset name="OMI-Aura_L3-OMTO3e_2014m0101_v003-2014m0103t013658.he5" ID="/opendap/hyrax/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0101_v003-2014m0103t013658.he5">
<thredds:dataSize units="bytes">3003100</thredds:dataSize>
<thredds:date type="modified">2014-01-03T06:48:48</thredds:date>
<thredds:access serviceName="dap" urlPath="/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0101_v003-2014m0103t013658.he5"/>
<thredds:access serviceName="wms" urlPath="?DATASET=lds/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0101_v003-2014m0103t013658.he5&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities"/>
</thredds:dataset>
<thredds:dataset name="OMI-Aura_L3-OMTO3e_2014m0102_v003-2014m0104t004027.he5" ID="/opendap/hyrax/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0102_v003-2014m0104t004027.he5">
<thredds:dataSize units="bytes">3030178</thredds:dataSize>
<thredds:date type="modified">2014-01-04T05:49:18</thredds:date>
<thredds:access serviceName="dap" urlPath="/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0102_v003-2014m0104t004027.he5"/>
<thredds:access serviceName="wms" urlPath="?DATASET=lds/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0102_v003-2014m0104t004027.he5&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities"/>
</thredds:dataset>
<thredds:dataset name="OMI-Aura_L3-OMTO3e_2014m0103_v003-2014m0105t013415.he5" ID="/opendap/hyrax/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0103_v003-2014m0105t013415.he5">
<thredds:dataSize units="bytes">3019723</thredds:dataSize>
<thredds:date type="modified">2014-01-05T06:49:33</thredds:date>
<thredds:access serviceName="dap" urlPath="/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0103_v003-2014m0105t013415.he5"/>
<thredds:access serviceName="wms" urlPath="?DATASET=lds/HDF-EOS5/Aura_OMI_Level3/OMTO3e.003/2014/OMI-Aura_L3-OMTO3e_2014m0103_v003-2014m0105t013415.he5&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities"/>
</thredds:dataset>
3003100
2014-01-03T06:48:48
3030178
2014-01-04T05:49:18
3019723
2014-01-05T06:49:33
您的属性不属于任何名称空间。在代码中,您试图获取元素而不是属性。我认为这样的东西应该可以工作,但还没有测试:rows.subjections().SelectMany(e=>e.Attribute(“name”).Where(a=>a!=null.ToArray()代码>我尝试了这个,但没有成功