<config>
<timeDifferenceFields>
<TimeDifference>
<StartTimeField>txt_SoReinigungUhrzeitvonZ1</StartTimeField>
<EndTimeField>txt_SoReinigungUhrzeitbisZ1</EndTimeField>
<OutputTimeField>txt_SoReinigungZ1</OutputTimeField>
</TimeDifference>
<TimeDifference>
<StartTimeField>txt_SoReinigungUhrzeitvonZ2</StartTimeField>
<EndTimeField>txt_SoReinigungUhrzeitbisZ2</EndTimeField>
<OutputTimeField>txt_SoReinigungZ2</OutputTimeField>
</TimeDifference>
<TimeDifference>
<StartTimeField>txt_SoReinigungUhrzeitvonZ3</StartTimeField>
<EndTimeField>txt_SoReinigungUhrzeitbisZ3</EndTimeField>
<OutputTimeField>txt_SoReinigungZ3</OutputTimeField>
</TimeDifference>
</timeDifferenceFields>
</config>
你好,
谁能帮我完成这个简单的任务,我不明白...
我想遍历上述 XML 文件中的 TimeDifference-Fields。对于每个 TimeDifference 节点,我想使用给定的 XML 值调用一个方法。
有了这个它会遇到一个NPE ...有人可以帮忙吗
XmlDocument configDoc = new XmlDocument();
configDoc.Load(configXml);
XmlNode timeFields = configDoc.SelectSingleNode("/config/timeDifferenceFields/TimeDifference");
foreach (XmlNode timeNode in timeFields)
{
String OutputTimeField = timeNode.SelectSingleNode("OutputTimeField").InnerXml;
String StartTimeField = timeNode.SelectSingleNode("StartTimeField").InnerXml;
String EndTimeField = timeNode.SelectSingleNode("EndTimeField").InnerXml;
addTimeDiffElement(inputDoc, OutputTimeField, StartTimeField, EndTimeField);
}