XML
HejJeg har følgende XML:
"<?xml version=\"1.0\" encoding=\"utf-8\"?><resource rel=\"contactPresence\" href=\"/ucwa/oauth/v1/applications/103315995678/people/lisa@kunde.dk/presence\" xmlns=\"http://schemas.microsoft.com/rtc/2012/03/ucwa\"><property name=\"availability\">Away</property><property name=\"deviceType\">PC</property><property name=\"lastActive\">2016-11-10T04:53:51.0000000</property></resource>"
Hvordan læser jeg den vha XMLreader
Jeg er kommer frem til følgende, men kan ikke gennemskue hvordan jeg læser værdierne ??
string a;
string xmlText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><resource rel=\"contactPresence\" href=\"/ucwa/oauth/v1/applications/103315995678/people/lisa@kunde.dk/presence\" xmlns=\"http://schemas.microsoft.com/rtc/2012/03/ucwa\"><property name=\"availability\">Away</property><property name=\"deviceType\">PC</property><property name=\"lastActive\">2016-11-10T04:53:51.0000000</property></resource>";
XmlTextReader xml01 = new XmlTextReader(new StringReader(xmlText));
while (xml01.Read())
{
Debug.WriteLine(xml01.Name);
switch (xml01.Name)
{
case "property":
switch (xml01.GetAttribute("name"))
{
case "availability":
a = "???";
break;
case "deviceType":
a = "???";
break;
case "lastActive":
a = "???";
break;
default:
break;
}
break;
default:
break;
}
}