我正在尝试从URL中读取XML中的天气数据.XML看起来像这样:
<weatherdata>
<location>...</location>
<credit>...</credit>
<links>...</links>
<meta>...</meta>
<sun rise="2013-05-11T04:49:22" set="2013-05-11T21:39:03"/>
<forecast>
<text>...</text>
<tabular>
<time from="2013-05-11T01:00:00" to="2013-05-11T06:00:00" period="0">
<!--
Valid from 2013-05-11T01:00:00 to 2013-05-11T06:00:00
-->
<symbol number="2" name="Fair" var="mf/02n.03"/>
<precipitation value="0" minvalue="0" maxvalue="0.1"/>
<!-- Valid at 2013-05-11T01:00:00 -->
<windDirection deg="173.8" code="S" name="South"/>
<windSpeed mps="4.2" name="Gentle breeze"/>
<temperature unit="celsius" value="9"/>
<pressure unit="hPa" value="1004.2"/>
</time>
</tabular>
</forecast>
<observations>...</observations>
</weatherdata>
Run Code Online (Sandbox Code Playgroud)
我对XML中的预测数据感兴趣.我想得到时间和时间,然后是天气数据.例如,温度在XML中如下所示:
<temperature unit="celsius" value="9"/>
Run Code Online (Sandbox Code Playgroud)
我想用这样的东西提取数据:
string fromTime = time from(the attribute in the xml);
string fromTime =time to(the attribute in the xml);
string name = …
Run Code Online (Sandbox Code Playgroud) 我有一个webservice方法,从格式为2012-11-18 11:21:03的 sql获取数据, 当我将它保存到C#字符串时,它变为这种格式:18.11.2012 11:21:03 如何将其更改回SQL格式2012-11-18 11:21:03?
我已经创建了一个具有许多不同方法的类库(DLL).并返回不同类型的数据(string string [] double double []).因此,我为包含不同数据类型的所有方法创建了一个名为CustomDataType的类,因此库中的每个方法都可以返回自定义类的对象,这样就可以返回我已经完成的多种数据类型:
public class CustomDataType
{
public double Value;
public string Timestamp;
public string Description;
public string Unit;
// special for GetparamterInfo
public string OpcItemUrl;
public string Source;
public double Gain;
public double Offset;
public string ParameterName;
public int ParameterID;
public double[] arrayOfValue;
public string[] arrayOfTimestamp;
//
public string[] arrayOfParameterName;
public string[] arrayOfUnit;
public string[] arrayOfDescription;
public int[] arrayOfParameterID;
public string[] arrayOfItemUrl;
public string[] arrayOfSource;
public string[] arrayOfModBusRegister;
public string[] arrayOfGain;
public string[] arrayOfOffset;
Run Code Online (Sandbox Code Playgroud)
}
该库包含以下方法: …
.net ×3
c# ×3
datetime ×1
object ×1
return-type ×1
sql ×1
xml ×1
xml-parsing ×1
xmldocument ×1