次の XML があります。
<UpsHistory>
<UpsSettings>
<Filename>modbusevent.xml</Filename>
<FileDate>04.02.1970</FileDate>
<FileTime>00:05:39</FileTime>
<Type>ENERTRONIC I 3-3 20kVA</Type>
<Location></Location>
<Phases>3</Phases>
<UpsContact>
<Company></Company>
<Department></Department>
<Contact></Contact>
<City></City>
<Street></Street>
<Phone></Phone>
</UpsContact>
</UpsSettings>
<UpsData id="1">
<Date>09.08.2012</Date>
<Time>12:05:53.52</Time>
<EventCode>574</EventCode>
<EventState>A</EventState>
<EventText><![CDATA[IGBT - DRIVERBOARD FAILURE]]></EventText>
<EventAction>/upsexe.cgi?cmd=2003&p1=574&reload=/mbevents.cgi&wait=5</EventAction>
</UpsData>
<UpsData id="2">
<Date>09.08.2012</Date>
<Time>11:23:08.88</Time>
<EventCode>606</EventCode>
<EventState>E</EventState>
<EventText><![CDATA[BYPASS VOLTAGE FAILURE]]></EventText>
<EventAction>/upsexe.cgi?cmd=2003&p1=606&reload=/mbevents.cgi&wait=5</EventAction>
</UpsData>
<UpsData id="3">
<Date>09.08.2012</Date>
<Time>11:23:07.06</Time>
<EventCode>1000</EventCode>
<EventState>E</EventState>
<EventText><![CDATA[CUSTOMER RELAY 1 ON]]></EventText>
<EventAction>/upsexe.cgi?cmd=2003&p1=1000&reload=/mbevents.cgi&wait=5</EventAction>
</UpsData>
<UpsData id="4">
<Date>09.08.2012</Date>
<Time>11:23:06.97</Time>
<EventCode>1003</EventCode>
<EventState>E</EventState>
<EventText><![CDATA[CUSTOMER RELAY 2 OFF]]></EventText>
<EventAction>/upsexe.cgi?cmd=2003&p1=1003&reload=/mbevents.cgi&wait=5</EventAction>
</UpsData>
...
<UpsData id="602">
<Date>08.09.2012</Date>
<Time>11:06:13.84</Time>
<EventCode>606</EventCode>
<EventState>E</EventState>
<EventText><![CDATA[BYPASS VOLTAGE FAILURE]]></EventText>
<EventAction>/upsexe.cgi?cmd=2003&p1=606&reload=/mbevents.cgi&wait=5</EventAction>
</UpsData>
</UpsHistory>
子要素の値を持つすべての UpsData 要素を取得したいのですが、UpsData 要素の ID のみを取得します。
ストリーム sw = CopyAndClose(response.GetResponseStream());
XmlTextReader rdr = new XmlTextReader(sw);
while (rdr.Read())
{
if (rdr.IsStartElement())
{
if (rdr.NodeType == XmlNodeType.Element)
{
if (rdr.Name == "UpsData")
{
rdr.MoveToAttribute("id");
if (rdr.Name == "Date")
{
ConsoleInfo(rdr.Value);
}
}
}
}
}
子要素の値を取得するにはどうすればよいですか? ありがとう!